/*
 * Copyright (c) 2018 Apple Inc. All Rights Reserved.
 *
 * @APPLE_LICENSE_HEADER_START@
 *
 * This file contains Original Code and/or Modifications of Original Code
 * as defined in and that are subject to the Apple Public Source License
 * Version 2.0 (the 'License'). You may not use this file except in
 * compliance with the License. Please obtain a copy of the License at
 * http://www.opensource.apple.com/apsl/ and read it before using this
 * file.
 *
 * The Original Code and all software distributed under the License are
 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
 * Please see the License for the specific language governing rights and
 * limitations under the License.
 *
 * @APPLE_LICENSE_HEADER_END@
 */

import Foundation

struct RawPolicy {
    let version: TPPolicyVersion
    let policyData: () -> String
    let plaintextPolicy: () -> TPPolicyDocument // functions are lazy, we don't need this except to validate the policies, and we only need to do that during unit tests

    func policyDoc() -> TPPolicyDocument {
        // validatePolicies was run during unit tests, so guarantees these will be non-nil, as they are hard-coded below
        guard let data = Data(base64Encoded: policyData()),
              let doc = TPPolicyDocument.policyDoc(withHash: version.policyHash, data: data) else {
            fatalError("encoded policy should be valid")
        }
        return doc
    }
}

let prevailingPolicyVersion = TPPolicyVersion(version: 20, hash: "SHA256:OIzjC3WyLGrM8GAd/EyIfVzTJdYmcGoKPFdQeWeRZTY=")

// Some peers don't know how to handle new policies when pairing. If we're pairing with one of those,
// we must prepare our identity using this policy.
let frozenPolicyVersion = TPPolicyVersion(version: 5, hash: "SHA256:O/ECQlWhvNlLmlDNh2+nal/yekUC87bXpV3k+6kznSo=")

private let logger = Logger(subsystem: "com.apple.security.trustedpeers", category: "policy")

private let reservedVersions: Set<TPCounter> = [14]

func rawPolicies() -> [RawPolicy] {[
    // These bytes are generated by tppolicy

    RawPolicy(
        version: TPPolicyVersion(version: 1, hash: "SHA256:TLXrcQmY4ue3oP5pCX1pwsi9BF8cKfohlJBilCroeBs="),
        policyData: { "CAESDgoGaVBob25lEgRmdWxsEgwKBGlQYWQSBGZ1bGwSCwoDTWFjEgRmdWxsEgwKBGlNYWMSBGZ1bGwSDQoHQXBwbGVUVhICdHYSDgoFV2F0Y2gSBXdhdGNoGhEKCVBDU0VzY3JvdxIEZnVsbBoXCgRXaUZpEgRmdWxsEgJ0dhIFd2F0Y2gaGQoRU2FmYXJpQ3JlZGl0Q2FyZHMSBGZ1bGwiDAoEZnVsbBIEZnVsbCIUCgV3YXRjaBIEZnVsbBIFd2F0Y2giDgoCdHYSBGZ1bGwSAnR2" },
        plaintextPolicy: {TPPolicyDocument(version: 1,
                                          modelToCategory: [
                                            TPPBPolicyModelToCategory(prefix: "iPhone", category: "full"),
                                            TPPBPolicyModelToCategory(prefix: "iPad", category: "full"),
                                            TPPBPolicyModelToCategory(prefix: "Mac", category: "full"),
                                            TPPBPolicyModelToCategory(prefix: "iMac", category: "full"),
                                            TPPBPolicyModelToCategory(prefix: "AppleTV", category: "tv"),
                                            TPPBPolicyModelToCategory(prefix: "Watch", category: "watch"),
                                          ],
                                          categoriesByView: [
                                            TPPBPolicyCategoriesByView(view: "PCSEscrow", categories: ["full"]),
                                            TPPBPolicyCategoriesByView(view: "WiFi", categories: ["full", "tv", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "SafariCreditCards", categories: ["full"]),
                                          ],
                                          introducersByCategory: [
                                            TPPBPolicyIntroducersByCategory(category: "full", introducers: ["full"]),
                                            TPPBPolicyIntroducersByCategory(category: "watch", introducers: ["full", "watch"]),
                                            TPPBPolicyIntroducersByCategory(category: "tv", introducers: ["full", "tv"]),
                                          ],
                                          redactions: [],
                                          keyViewMapping: [],
                                          userControllableViewList: [],
                                          piggybackViews: [],
                                          priorityViews: [],
                                          inheritedExcludedViews: [],
                                          hashAlgo: .SHA256)}),

    RawPolicy(
        version: TPPolicyVersion(version: 2, hash: "SHA256:ZL1WBUCyO155rHBJQeghomCCKGmfjtS0jvsK+UEvx5o="),
        policyData: { "CAISDgoGaUN5Y2xlEgRmdWxsEg4KBmlQaG9uZRIEZnVsbBIMCgRpUGFkEgRmdWxsEgsKA01hYxIEZnVsbBIMCgRpTWFjEgRmdWxsEg0KB0FwcGxlVFYSAnR2Eg4KBVdhdGNoEgV3YXRjaBoRCglQQ1NFc2Nyb3cSBGZ1bGwaFwoEV2lGaRIEZnVsbBICdHYSBXdhdGNoGhkKEVNhZmFyaUNyZWRpdENhcmRzEgRmdWxsIgwKBGZ1bGwSBGZ1bGwiFAoFd2F0Y2gSBGZ1bGwSBXdhdGNoIg4KAnR2EgRmdWxsEgJ0dg==" },
        plaintextPolicy: {TPPolicyDocument(version: 2,
                                          modelToCategory: [
                                            TPPBPolicyModelToCategory(prefix: "iCycle", category: "full"),
                                            TPPBPolicyModelToCategory(prefix: "iPhone", category: "full"),
                                            TPPBPolicyModelToCategory(prefix: "iPad", category: "full"),
                                            TPPBPolicyModelToCategory(prefix: "Mac", category: "full"),
                                            TPPBPolicyModelToCategory(prefix: "iMac", category: "full"),
                                            TPPBPolicyModelToCategory(prefix: "AppleTV", category: "tv"),
                                            TPPBPolicyModelToCategory(prefix: "Watch", category: "watch"),
                                          ],
                                          categoriesByView: [
                                            TPPBPolicyCategoriesByView(view: "PCSEscrow", categories: ["full"]),
                                            TPPBPolicyCategoriesByView(view: "WiFi", categories: ["full", "tv", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "SafariCreditCards", categories: ["full"]),
                                          ],
                                          introducersByCategory: [
                                            TPPBPolicyIntroducersByCategory(category: "full", introducers: ["full"]),
                                            TPPBPolicyIntroducersByCategory(category: "watch", introducers: ["full", "watch"]),
                                            TPPBPolicyIntroducersByCategory(category: "tv", introducers: ["full", "tv"]),
                                          ],
                                          redactions: [],
                                          keyViewMapping: [],
                                          userControllableViewList: [],
                                          piggybackViews: [],
                                          priorityViews: [],
                                          inheritedExcludedVi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QQ1NNYWlsRHJvcCQSGgAEIhYCBHZ3aHQKDl5QQ1NNYXN0ZXJLZXkkEhYABCISAgR2d2h0CgpeUENTTm90ZXMkEhcABCITAgR2d2h0CgteUENTUGhvdG9zJBIYAAQiFAIEdndodAoMXlBDU1NoYXJpbmckEh0ABCIZAgR2d2h0ChFeUENTaUNsb3VkQmFja3VwJBIcAAQiGAIEdndodAoQXlBDU2lDbG91ZERyaXZlJBIZAAQiFQIEdndodAoNXlBDU2lNZXNzYWdlJBIVUHJvdGVjdGVkQ2xvdWRTdG9yYWdlMkAKKwAEIicCBGFncnAKH15jb20uYXBwbGUuc2FmYXJpLmNyZWRpdC1jYXJkcyQSEVNhZmFyaUNyZWRpdENhcmRzMjQKIQAEIh0CBGFncnAKFV5jb20uYXBwbGUuY2ZuZXR3b3JrJBIPU2FmYXJpUGFzc3dvcmRzMm0KXAACEh4ABCIaAgR2d2h0ChJeQWNjZXNzb3J5UGFpcmluZyQSGgAEIhYCBHZ3aHQKDl5OYW5vUmVnaXN0cnkkEhwABCIYAgR2d2h0ChBeV2F0Y2hNaWdyYXRpb24kEg1EZXZpY2VQYWlyaW5nMi0KIQAEIh0CBGFncnAKFV5jb20uYXBwbGUuY2ZuZXR3b3JrJBIIQmFja3N0b3A=" },
        plaintextPolicy: {TPPolicyDocument(version: 3,
                                          modelToCategory: [
                                            TPPBPolicyModelToCategory(prefix: "iPhone", category: "full"),
                                            TPPBPolicyModelToCategory(prefix: "iPad", category: "full"),
                                            TPPBPolicyModelToCategory(prefix: "Mac", category: "full"),
                                            TPPBPolicyModelToCategory(prefix: "iMac", category: "full"),
                                            TPPBPolicyModelToCategory(prefix: "AppleTV", category: "tv"),
                                            TPPBPolicyModelToCategory(prefix: "Watch", category: "watch"),
                                            TPPBPolicyModelToCategory(prefix: "AudioAccessory", category: "audio"),
                                          ],
                                          categoriesByView: [
                                            TPPBPolicyCategoriesByView(view: "DevicePairing", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "ApplePay", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "ProtectedCloudStorage", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "Backstop", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "AutoUnlock", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "SecureObjectSync", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "SafariCreditCards", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "Home", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "SafariPasswords", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "Applications", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "Engram", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "LimitedPeersAllowed", categories: ["full", "watch", "tv", "audio"]),
                                            TPPBPolicyCategoriesByView(view: "Manatee", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "WiFi", categories: ["full", "watch", "tv", "audio"]),
                                            TPPBPolicyCategoriesByView(view: "Health", categories: ["full", "watch"]),
                                          ],
                                          introducersByCategory: [
                                            TPPBPolicyIntroducersByCategory(category: "full", introducers: ["full", "watch"]),
                                            TPPBPolicyIntroducersByCategory(category: "audio", introducers: ["full", "watch", "audio"]),
                                            TPPBPolicyIntroducersByCategory(category: "watch", introducers: ["full", "watch"]),
                                            TPPBPolicyIntroducersByCategory(category: "tv", introducers: ["full", "watch", "tv"]),
                                          ],
                                          redactions: [],
                                          keyViewMapping: [
                                            TPPBPolicyKeyViewMapping(view: "ApplePay", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^ApplePay$")),
                                            TPPBPolicyKeyViewMapping(view: "AutoUnlock", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^AutoUnlock$")),
                                            TPPBPolicyKeyViewMapping(view: "Engram", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^Engram$")),
                                            TPPBPolicyKeyViewMapping(view: "Health", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^Health$")),
                                            TPPBPolicyKeyViewMapping(view: "Home", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^Home$")),
                                            TPPBPolicyKeyViewMapping(view: "Manatee", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^Manatee$")),
                                            TPPBPolicyKeyViewMapping(view: "LimitedPeersAllowed", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^LimitedPeersAllowed$")),

                                            // These items will not be synced by Octagon
                                            TPPBPolicyKeyViewMapping(view: "NotSynced", matchingRule:
                                                                        TPDictionaryMatchingRule.orMatch([
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^ContinuityUnlock$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^HomeKit$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^AppleTV$"),
                                                                        ])),

                                            TPPBPolicyKeyViewMapping(view: "Applications", matchingRule:
                                                                        TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^[0-9A-Z]{10}\\.")),

                                            TPPBPolicyKeyViewMapping(view: "SecureObjectSync", matchingRule:
                                                                        TPDictionaryMatchingRule.orMatch([
                                                                            TPDictionaryMatchingRule.andMatch([
                                                                                TPDictionaryMatchingRule.fieldMatch("class", fieldRegex: "^genp$"),
                                                                                TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com.apple.sbd$"),
                                                                            ]),
                                                                            TPDictionaryMatchingRule.andMatch([
                                                                                TPDictionaryMatchingRule.fieldMatch("class", fieldRegex: "^keys$"),
                                                                                TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com.apple.security.sos$"),
                                                                            ]),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^BackupBagV0$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^iCloudIdentity$"),
                                                                        ])),

                                            TPPBPolicyKeyViewMapping(view: "WiFi", matchingRule:
                                                                        TPDictionaryMatchingRule.orMatch([
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^WiFi$"),
                                                                            TPDictionaryMatchingRule.andMatch([
                                                                                TPDictionaryMatchingRule.fieldMatch("class", fieldRegex: "^genp$"),
                                                                                TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^apple$"),
                                                                                TPDictionaryMatchingRule.fieldMatch("svce", fieldRegex: "^AirPort$"),
                                                                            ]),
                                                                        ])),

                                            TPPBPolicyKeyViewMapping(view: "ProtectedCloudStorage", matchingRule:
                                                                        TPDictionaryMatchingRule.orMatch([
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCSCloudKit$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCSEscrow$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCSFDE$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCSFeldspar$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCSMailDrop$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCSMasterKey$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCSNotes$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCSPhotos$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCSSharing$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCSiCloudBackup$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCSiCloudDrive$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCSiMessage$"),
                                                                        ])),

                                            TPPBPolicyKeyViewMapping(view: "SafariCreditCards",
                                                                     matchingRule: TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com.apple.safari.credit-cards$")),

                                            TPPBPolicyKeyViewMapping(view: "SafariPasswords",
                                                                     matchingRule: TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com.apple.cfnetwork$")),

                                            TPPBPolicyKeyViewMapping(view: "DevicePairing", matchingRule:
                                                                        TPDictionaryMatchingRule.orMatch([
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^AccessoryPairing$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^NanoRegistry$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^WatchMigration$"),
                                                                        ])),

                                            TPPBPolicyKeyViewMapping(view: "Backstop",
                                                                     matchingRule: TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com.apple.cfnetwork$")),
                                          ],
                                          userControllableViewList: [],
                                          piggybackViews: [],
                                          priorityViews: [],
                                          inheritedExcludedViews: [],
                                          hashAlgo: .SHA256)}),

    RawPolicy(
        version: TPPolicyVersion(version: 4, hash: "SHA256:Tjdu5QrWGvKWMx7k3VWFrEWSsBDPZAwCql9ybDkvFs8="),
        policyData: { "CAQSDgoGaVBob25lEgRmdWxsEgwKBGlQYWQSBGZ1bGwSCwoDTWFjEgRmdWxsEgwKBGlNYWMSBGZ1bGwSDQoHQXBwbGVUVhICdHYSDgoFV2F0Y2gSBXdhdGNoEhcKDkF1ZGlvQWNjZXNzb3J5EgVhdWRpbxoTCgRIb21lEgRmdWxsEgV3YXRjaBobCgxBcHBsaWNhdGlvbnMSBGZ1bGwSBXdhdGNoGh4KBFdpRmkSBGZ1bGwSBXdhdGNoEgJ0dhIFYXVkaW8aGQoKQXV0b1VubG9jaxIEZnVsbBIFd2F0Y2gaFwoIQXBwbGVQYXkSBGZ1bGwSBXdhdGNoGhUKBkhlYWx0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OXk5hbm9SZWdpc3RyeSQSHAAEIhgCBHZ3aHQKEF5XYXRjaE1pZ3JhdGlvbiQSDURldmljZVBhaXJpbmc=" },
        plaintextPolicy: {TPPolicyDocument(version: 4,
                                          modelToCategory: [
                                            TPPBPolicyModelToCategory(prefix: "iPhone", category: "full"),
                                            TPPBPolicyModelToCategory(prefix: "iPad", category: "full"),
                                            TPPBPolicyModelToCategory(prefix: "Mac", category: "full"),
                                            TPPBPolicyModelToCategory(prefix: "iMac", category: "full"),
                                            TPPBPolicyModelToCategory(prefix: "AppleTV", category: "tv"),
                                            TPPBPolicyModelToCategory(prefix: "Watch", category: "watch"),
                                            TPPBPolicyModelToCategory(prefix: "AudioAccessory", category: "audio"),
                                          ],
                                          categoriesByView: [
                                            TPPBPolicyCategoriesByView(view: "Home", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "Applications", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "WiFi", categories: ["full", "watch", "tv", "audio"]),
                                            TPPBPolicyCategoriesByView(view: "AutoUnlock", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "ApplePay", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "Health", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "Manatee", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "LimitedPeersAllowed", categories: ["full", "watch", "tv", "audio"]),
                                            TPPBPolicyCategoriesByView(view: "ProtectedCloudStorage", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "Passwords", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "DevicePairing", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "SecureObjectSync", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "Engram", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "CreditCards", categories: ["full", "watch"]),
                                          ],
                                          introducersByCategory: [
                                            TPPBPolicyIntroducersByCategory(category: "audio", introducers: ["full", "watch", "audio"]),
                                            TPPBPolicyIntroducersByCategory(category: "full", introducers: ["full", "watch"]),
                                            TPPBPolicyIntroducersByCategory(category: "watch", introducers: ["full", "watch"]),
                                            TPPBPolicyIntroducersByCategory(category: "tv", introducers: ["full", "watch", "tv"]),
                                          ],
                                          redactions: [],
                                          keyViewMapping: [
                                            TPPBPolicyKeyViewMapping(view: "ApplePay", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^ApplePay$")),
                                            TPPBPolicyKeyViewMapping(view: "AutoUnlock", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^AutoUnlock$")),
                                            TPPBPolicyKeyViewMapping(view: "Engram", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^Engram$")),
                                            TPPBPolicyKeyViewMapping(view: "Health", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^Health$")),
                                            TPPBPolicyKeyViewMapping(view: "Home", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^Home$")),
                                            TPPBPolicyKeyViewMapping(view: "Manatee", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^Manatee$")),
                                            TPPBPolicyKeyViewMapping(view: "LimitedPeersAllowed", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^LimitedPeersAllowed$")),

                                            // These items will not be synced by Octagon
                                            TPPBPolicyKeyViewMapping(view: "NotSynced", matchingRule:
                                                                        TPDictionaryMatchingRule.orMatch([
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^ContinuityUnlock$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^HomeKit$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^AppleTV$"),
                                                                        ])),

                                            TPPBPolicyKeyViewMapping(view: "Applications", matchingRule:
                                                                        TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^[0-9A-Z]{10}\\.")),

                                            TPPBPolicyKeyViewMapping(view: "SecureObjectSync", matchingRule:
                                                                        TPDictionaryMatchingRule.orMatch([
                                                                            TPDictionaryMatchingRule.andMatch([
                                                                                TPDictionaryMatchingRule.fieldMatch("class", fieldRegex: "^genp$"),
                                                                                TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com.apple.sbd$"),
                                                                            ]),
                                                                            TPDictionaryMatchingRule.andMatch([
                                                                                TPDictionaryMatchingRule.fieldMatch("class", fieldRegex: "^keys$"),
                                                                                TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com.apple.security.sos$"),
                                                                            ]),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^BackupBagV0$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^iCloudIdentity$"),
                                                                        ])),

                                            TPPBPolicyKeyViewMapping(view: "WiFi", matchingRule:
                                                                        TPDictionaryMatchingRule.orMatch([
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^WiFi$"),
                                                                            TPDictionaryMatchingRule.andMatch([
                                                                                TPDictionaryMatchingRule.fieldMatch("class", fieldRegex: "^genp$"),
                                                                                TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^apple$"),
                                                                                TPDictionaryMatchingRule.fieldMatch("svce", fieldRegex: "^AirPort$"),
                                                                            ]),
                                                                        ])),

                                            TPPBPolicyKeyViewMapping(view: "ProtectedCloudStorage", matchingRule:
                                                                        TPDictionaryMatchingRule.orMatch([
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-CloudKit$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-Escrow$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-FDE$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-Feldspar$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-MailDrop$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-MasterKey$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-Notes$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-Photos$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-Sharing$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-iCloudBackup$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-iCloudDrive$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-iMessage$"),
                                                                        ])),

                                            TPPBPolicyKeyViewMapping(view: "CreditCards",
                                                                     matchingRule: TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com.apple.safari.credit-cards$")),

                                            TPPBPolicyKeyViewMapping(view: "Passwords",
                                                                     matchingRule: TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com.apple.cfnetwork$")),

                                            TPPBPolicyKeyViewMapping(view: "DevicePairing", matchingRule:
                                                                        TPDictionaryMatchingRule.orMatch([
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^AccessoryPairing$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^NanoRegistry$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^WatchMigration$"),
                                                                        ])),
                                          ],
                                          userControllableViewList: [],
                                          piggybackViews: [],
                                          priorityViews: [],
                                          inheritedExcludedViews: [],
                                          hashAlgo: .SHA256)}),

    RawPolicy(
        version: TPPolicyVersion(version: 5, hash: "SHA256:O/ECQlWhvNlLmlDNh2+nal/yekUC87bXpV3k+6kznSo="),
        policyData: { "CAUSDgoGaVBob25lEgRmdWxsEgwKBG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EIhQCBHZ3aHQKDF5QQ1MtUGhvdG9zJBIZAAQiFQIEdndodAoNXlBDUy1TaGFyaW5nJBIeAAQiGgIEdndodAoSXlBDUy1pQ2xvdWRCYWNrdXAkEh0ABCIZAgR2d2h0ChFeUENTLWlDbG91ZERyaXZlJBIaAAQiFgIEdndodAoOXlBDUy1pTWVzc2FnZSQSFVByb3RlY3RlZENsb3VkU3RvcmFnZTI6CisABCInAgRhZ3JwCh9eY29tLmFwcGxlLnNhZmFyaS5jcmVkaXQtY2FyZHMkEgtDcmVkaXRDYXJkczIuCiEABCIdAgRhZ3JwChVeY29tLmFwcGxlLmNmbmV0d29yayQSCVBhc3N3b3JkczJtClwAAhIeAAQiGgIEdndodAoSXkFjY2Vzc29yeVBhaXJpbmckEhoABCIWAgR2d2h0Cg5eTmFub1JlZ2lzdHJ5JBIcAAQiGAIEdndodAoQXldhdGNoTWlncmF0aW9uJBINRGV2aWNlUGFpcmluZzIOCgIABhIIQmFja3N0b3A=" },
        plaintextPolicy: {TPPolicyDocument(version: 5,
                                          modelToCategory: [
                                            TPPBPolicyModelToCategory(prefix: "iPhone", category: "full"),
                                            TPPBPolicyModelToCategory(prefix: "iPad", category: "full"),
                                            TPPBPolicyModelToCategory(prefix: "iPod", category: "full"),
                                            TPPBPolicyModelToCategory(prefix: "Mac", category: "full"),
                                            TPPBPolicyModelToCategory(prefix: "iMac", category: "full"),
                                            TPPBPolicyModelToCategory(prefix: "AppleTV", category: "tv"),
                                            TPPBPolicyModelToCategory(prefix: "Watch", category: "watch"),
                                            TPPBPolicyModelToCategory(prefix: "AudioAccessory", category: "audio"),
                                          ],
                                          categoriesByView: [
                                            TPPBPolicyCategoriesByView(view: "Applications", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "SecureObjectSync", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "DevicePairing", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "CreditCards", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "Health", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "LimitedPeersAllowed", categories: ["full", "watch", "tv", "audio"]),
                                            TPPBPolicyCategoriesByView(view: "ProtectedCloudStorage", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "ApplePay", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "AutoUnlock", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "Manatee", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "Passwords", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "Engram", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "WiFi", categories: ["full", "watch", "tv", "audio"]),
                                            TPPBPolicyCategoriesByView(view: "Home", categories: ["full", "watch"]),
                                          ],
                                          introducersByCategory: [
                                            TPPBPolicyIntroducersByCategory(category: "audio", introducers: ["full", "watch", "audio"]),
                                            TPPBPolicyIntroducersByCategory(category: "full", introducers: ["full", "watch"]),
                                            TPPBPolicyIntroducersByCategory(category: "tv", introducers: ["full", "watch", "tv"]),
                                            TPPBPolicyIntroducersByCategory(category: "watch", introducers: ["full", "watch"]),
                                          ],
                                          redactions: [],
                                          keyViewMapping: [
                                            TPPBPolicyKeyViewMapping(view: "ApplePay", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^ApplePay$")),
                                            TPPBPolicyKeyViewMapping(view: "AutoUnlock", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^AutoUnlock$")),
                                            TPPBPolicyKeyViewMapping(view: "Engram", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^Engram$")),
                                            TPPBPolicyKeyViewMapping(view: "Health", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^Health$")),
                                            TPPBPolicyKeyViewMapping(view: "Home", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^Home$")),
                                            TPPBPolicyKeyViewMapping(view: "Manatee", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^Manatee$")),
                                            TPPBPolicyKeyViewMapping(view: "LimitedPeersAllowed", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^LimitedPeersAllowed$")),

                                            // These items will not be synced by Octagon
                                            TPPBPolicyKeyViewMapping(view: "NotSynced", matchingRule:
                                                                        TPDictionaryMatchingRule.orMatch([
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^ContinuityUnlock$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^HomeKit$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^AppleTV$"),
                                                                        ])),

                                            TPPBPolicyKeyViewMapping(view: "Applications", matchingRule:
                                                                        TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^[0-9A-Z]{10}\\.")),

                                            TPPBPolicyKeyViewMapping(view: "SecureObjectSync", matchingRule:
                                                                        TPDictionaryMatchingRule.orMatch([
                                                                            TPDictionaryMatchingRule.andMatch([
                                                                                TPDictionaryMatchingRule.fieldMatch("class", fieldRegex: "^genp$"),
                                                                                TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com.apple.sbd$"),
                                                                            ]),
                                                                            TPDictionaryMatchingRule.andMatch([
                                                                                TPDictionaryMatchingRule.fieldMatch("class", fieldRegex: "^keys$"),
                                                                                TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com.apple.security.sos$"),
                                                                            ]),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^BackupBagV0$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^iCloudIdentity$"),
                                                                        ])),

                                            TPPBPolicyKeyViewMapping(view: "WiFi", matchingRule:
                                                                        TPDictionaryMatchingRule.orMatch([
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^WiFi$"),
                                                                            TPDictionaryMatchingRule.andMatch([
                                                                                TPDictionaryMatchingRule.fieldMatch("class", fieldRegex: "^genp$"),
                                                                                TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^apple$"),
                                                                                TPDictionaryMatchingRule.fieldMatch("svce", fieldRegex: "^AirPort$"),
                                                                            ]),
                                                                        ])),

                                            TPPBPolicyKeyViewMapping(view: "ProtectedCloudStorage", matchingRule:
                                                                        TPDictionaryMatchingRule.orMatch([
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-Backup$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-CloudKit$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-Escrow$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-FDE$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-Feldspar$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-MailDrop$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-Maildrop$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-MasterKey$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-Notes$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-Photos$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-Sharing$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-iCloudBackup$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-iCloudDrive$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-iMessage$"),
                                                                        ])),

                                            TPPBPolicyKeyViewMapping(view: "CreditCards",
                                                                     matchingRule: TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com.apple.safari.credit-cards$")),

                                            TPPBPolicyKeyViewMapping(view: "Passwords",
                                                                     matchingRule: TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com.apple.cfnetwork$")),

                                            TPPBPolicyKeyViewMapping(view: "DevicePairing", matchingRule:
                                                                        TPDictionaryMatchingRule.orMatch([
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^AccessoryPairing$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^NanoRegistry$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^WatchMigration$"),
                                                                        ])),

                                            TPPBPolicyKeyViewMapping(view: "Backstop", matchingRule:
                                                                        TPDictionaryMatchingRule.trueMatch()),
                                          ],
                                          userControllableViewList: [],
                                          piggybackViews: [],
                                          priorityViews: [],
                                          inheritedExcludedViews: [],
                                          hashAlgo: .SHA256)}),

    RawPolicy(
        version: TPPolicyVersion(version: 6, hash: "SHA256:L2Px1aYyR1tgChe8dIyTBSmCHCWEFJirZ3ELMFXz2PY="),
        policyData: { "CAYSDgoGaVBob25lEgRmdWxsEgwKBGlQYWQSBGZ1bGwSDAoEaVBvZBIEZnVsbBILCgNNYWMSBGZ1bGwSDAoEaU1hYxIEZnVsbBINCgdBcHBsZVRWEgJ0dhIOCgVXYXRjaBIFd2F0Y2gSFwoOQXVkaW9BY2Nlc3NvcnkSBWF1ZGlvGhoKC0NyZWRpdENhcmRzEgRmdWxsEgV3YXRjaBofChBTZWN1cmVPYmplY3RTeW5jEgRmdWxsEgV3YXRjaBoVCgZIZWFsdGgSBGZ1bGwSBXdhdGNoGhkKCkF1dG9VbmxvY2sSBGZ1bGwSBXdhdGNoGh4KBFdpRmkSBGZ1bGwSBXdhdGNoEgJ0dhIFYXVkaW8aHgoESG9tZRIEZnVsbBIFd2F0Y2gSAnR2EgVhdWRpbxokChVQcm90ZWN0ZWRD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XkFjY2Vzc29yeVBhaXJpbmckEhoABCIWAgR2d2h0Cg5eTmFub1JlZ2lzdHJ5JBIcAAQiGAIEdndodAoQXldhdGNoTWlncmF0aW9uJBINRGV2aWNlUGFpcmluZzIOCgIABhIIQmFja3N0b3A=" },
        plaintextPolicy: {TPPolicyDocument(version: 6,
                                          modelToCategory: [
                                            TPPBPolicyModelToCategory(prefix: "iPhone", category: "full"),
                                            TPPBPolicyModelToCategory(prefix: "iPad", category: "full"),
                                            TPPBPolicyModelToCategory(prefix: "iPod", category: "full"),
                                            TPPBPolicyModelToCategory(prefix: "Mac", category: "full"),
                                            TPPBPolicyModelToCategory(prefix: "iMac", category: "full"),
                                            TPPBPolicyModelToCategory(prefix: "AppleTV", category: "tv"),
                                            TPPBPolicyModelToCategory(prefix: "Watch", category: "watch"),
                                            TPPBPolicyModelToCategory(prefix: "AudioAccessory", category: "audio"),
                                          ],
                                          categoriesByView: [
                                            TPPBPolicyCategoriesByView(view: "CreditCards", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "SecureObjectSync", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "Health", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "AutoUnlock", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "WiFi", categories: ["full", "watch", "tv", "audio"]),
                                            TPPBPolicyCategoriesByView(view: "Home", categories: ["full", "watch", "tv", "audio"]),
                                            TPPBPolicyCategoriesByView(view: "ProtectedCloudStorage", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "LimitedPeersAllowed", categories: ["full", "watch", "tv", "audio"]),
                                            TPPBPolicyCategoriesByView(view: "Passwords", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "Applications", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "DevicePairing", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "ApplePay", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "Manatee", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "Engram", categories: ["full", "watch"]),
                                          ],
                                          introducersByCategory: [
                                            TPPBPolicyIntroducersByCategory(category: "audio", introducers: ["full", "watch", "audio"]),
                                            TPPBPolicyIntroducersByCategory(category: "tv", introducers: ["full", "watch", "tv"]),
                                            TPPBPolicyIntroducersByCategory(category: "watch", introducers: ["full", "watch"]),
                                            TPPBPolicyIntroducersByCategory(category: "full", introducers: ["full", "watch"]),
                                          ],
                                          redactions: [],
                                          keyViewMapping: [
                                            TPPBPolicyKeyViewMapping(view: "ApplePay", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^ApplePay$")),
                                            TPPBPolicyKeyViewMapping(view: "AutoUnlock", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^AutoUnlock$")),
                                            TPPBPolicyKeyViewMapping(view: "Engram", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^Engram$")),
                                            TPPBPolicyKeyViewMapping(view: "Health", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^Health$")),
                                            TPPBPolicyKeyViewMapping(view: "Home", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^Home$")),
                                            TPPBPolicyKeyViewMapping(view: "Manatee", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^Manatee$")),
                                            TPPBPolicyKeyViewMapping(view: "LimitedPeersAllowed", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^LimitedPeersAllowed$")),

                                            // These items will not be synced by Octagon
                                            TPPBPolicyKeyViewMapping(view: "NotSynced", matchingRule:
                                                                        TPDictionaryMatchingRule.orMatch([
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^ContinuityUnlock$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^HomeKit$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^AppleTV$"),
                                                                        ])),

                                            TPPBPolicyKeyViewMapping(view: "Applications", matchingRule:
                                                                        TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^[0-9A-Z]{10}\\.")),

                                            TPPBPolicyKeyViewMapping(view: "SecureObjectSync", matchingRule:
                                                                        TPDictionaryMatchingRule.orMatch([
                                                                            TPDictionaryMatchingRule.andMatch([
                                                                                TPDictionaryMatchingRule.fieldMatch("class", fieldRegex: "^genp$"),
                                                                                TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com\\.apple\\.sbd$"),
                                                                            ]),
                                                                            TPDictionaryMatchingRule.andMatch([
                                                                                TPDictionaryMatchingRule.fieldMatch("class", fieldRegex: "^keys$"),
                                                                                TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com\\.apple\\.security\\.sos$"),
                                                                            ]),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^BackupBagV0$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^iCloudIdentity$"),
                                                                        ])),

                                            TPPBPolicyKeyViewMapping(view: "WiFi", matchingRule:
                                                                        TPDictionaryMatchingRule.orMatch([
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^WiFi$"),
                                                                            TPDictionaryMatchingRule.andMatch([
                                                                                TPDictionaryMatchingRule.fieldMatch("class", fieldRegex: "^genp$"),
                                                                                TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^apple$"),
                                                                                TPDictionaryMatchingRule.fieldMatch("svce", fieldRegex: "^AirPort$"),
                                                                            ]),
                                                                        ])),

                                            TPPBPolicyKeyViewMapping(view: "ProtectedCloudStorage", matchingRule:
                                                                        TPDictionaryMatchingRule.orMatch([
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-Backup$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-CloudKit$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-Escrow$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-FDE$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-Feldspar$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-MailDrop$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-Maildrop$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-MasterKey$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-Notes$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-Photos$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-Sharing$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-iCloudBackup$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-iCloudDrive$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-iMessage$"),
                                                                        ])),

                                            TPPBPolicyKeyViewMapping(view: "CreditCards",
                                                                     matchingRule: TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com\\.apple\\.safari\\.credit-cards$")),

                                            TPPBPolicyKeyViewMapping(view: "Passwords",
                                                                     matchingRule: TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com\\.apple\\.cfnetwork$")),

                                            TPPBPolicyKeyViewMapping(view: "DevicePairing", matchingRule:
                                                                        TPDictionaryMatchingRule.orMatch([
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^AccessoryPairing$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^NanoRegistry$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^WatchMigration$"),
                                                                        ])),

                                            TPPBPolicyKeyViewMapping(view: "Backstop", matchingRule:
                                                                        TPDictionaryMatchingRule.trueMatch()),
                                          ],
                                          userControllableViewList: [],
                                          piggybackViews: [],
                                          priorityViews: [],
                                          inheritedExcludedViews: [],
                                          hashAlgo: .SHA256)}),

    RawPolicy(
        version: TPPolicyVersion(version: 7, hash: "SHA256:dL8Qujqzprhp6FdH5GzNMtPlnZtLWMwfiiF7aykr8WU="),
        policyData: { "CAcSDgoGaVBob25lEgRmdWxsEgwKBGlQYWQSBGZ1bGwSDAoEaVBvZBIEZnVsbBILCgNNYWMSBGZ1bGwSDAoEaU1hYxIEZnVsbBINCgdBcHBsZVRWEgJ0dhIOCgVXYXRjaBIFd2F0Y2gSFwoOQXVkaW9BY2Nlc3NvcnkSBWF1ZGlvGh4KBEhvbWUSBGZ1bGwSBXdhdGNoEgJ0dhIFYXVkaW8aJAoVUHJvdGVjdGVkQ2xvdWRTdG9yYWdlEgRmdWxsEgV3YXRjaBoYCglQYXNzd29yZHMSBGZ1bGwSBXdhdGNoGh8KEFNlY3VyZU9iamVjdFN5bmMSBGZ1bGwSBXdhdGNoGh4KBFdpRmkSBGZ1bGwSBXdhdGNoEgJ0dhIFYXVkaW8aGgoLQ3JlZGl0Q2FyZHMSBGZ1bGwSBXdhdGNoGhcKCEFwcGxlUGF5EgRmdWxsEgV3YXRjaBoVCgZIZWFsdGgSBGZ1bGwSBXdhdGNoGhkKCkF1dG9VbmxvY2sSBGZ1bGwSBXdhdGNoGi0KE0xpbWl0ZWRQZWVyc0FsbG93ZWQSBGZ1bGwSBXdhdGNoEgJ0dhIFYXVkaW8aHAoNRGV2aWNlUGFpcmluZxIEZnVsbBIFd2F0Y2gaFgoHTWFuYXRlZRIEZnVsbBIFd2F0Y2gaFQoGRW5ncmFtEgRmdWxsEgV3YXRjaBoXCghCYWNrc3RvcBIEZnVsbBIFd2F0Y2gaGwoMQXBwbGljYXRpb25zEgRmdWxsEgV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CV5BaXJQb3J0JBIEV2lGaTKdAwqDAwACEhgABCIUAgR2d2h0CgxeUENTLUJhY2t1cCQSGgAEIhYCBHZ3aHQKDl5QQ1MtQ2xvdWRLaXQkEhgABCIUAgR2d2h0CgxeUENTLUVzY3JvdyQSFQAEIhECBHZ3aHQKCV5QQ1MtRkRFJBIaAAQiFgIEdndodAoOXlBDUy1GZWxkc3BhciQSGgAEIhYCBHZ3aHQKDl5QQ1MtTWFpbERyb3AkEhoABCIWAgR2d2h0Cg5eUENTLU1haWxkcm9wJBIbAAQiFwIEdndodAoPXlBDUy1NYXN0ZXJLZXkkEhcABCITAgR2d2h0CgteUENTLU5vdGVzJBIYAAQiFAIEdndodAoMXlBDUy1QaG90b3MkEhkABCIVAgR2d2h0Cg1eUENTLVNoYXJpbmckEh4ABCIaAgR2d2h0ChJeUENTLWlDbG91ZEJhY2t1cCQSHQAEIhkCBHZ3aHQKEV5QQ1MtaUNsb3VkRHJpdmUkEhoABCIWAgR2d2h0Cg5eUENTLWlNZXNzYWdlJBIVUHJvdGVjdGVkQ2xvdWRTdG9yYWdlMj0KLgAEIioCBGFncnAKIl5jb21cLmFwcGxlXC5zYWZhcmlcLmNyZWRpdC1jYXJkcyQSC0NyZWRpdENhcmRzMjAKIwAEIh8CBGFncnAKF15jb21cLmFwcGxlXC5jZm5ldHdvcmskEglQYXNzd29yZHMybQpcAAISHgAEIhoCBHZ3aHQKEl5BY2Nlc3NvcnlQYWlyaW5nJBIaAAQiFgIEdndodAoOXk5hbm9SZWdpc3RyeSQSHAAEIhgCBHZ3aHQKEF5XYXRjaE1pZ3JhdGlvbiQSDURldmljZVBhaXJpbmcyDgoCAAYSCEJhY2tzdG9w" },
        plaintextPolicy: {TPPolicyDocument(version: 7,
                                          modelToCategory: [
                                            TPPBPolicyModelToCategory(prefix: "iPhone", category: "full"),
                                            TPPBPolicyModelToCategory(prefix: "iPad", category: "full"),
                                            TPPBPolicyModelToCategory(prefix: "iPod", category: "full"),
                                            TPPBPolicyModelToCategory(prefix: "Mac", category: "full"),
                                            TPPBPolicyModelToCategory(prefix: "iMac", category: "full"),
                                            TPPBPolicyModelToCategory(prefix: "AppleTV", category: "tv"),
                                            TPPBPolicyModelToCategory(prefix: "Watch", category: "watch"),
                                            TPPBPolicyModelToCategory(prefix: "AudioAccessory", category: "audio"),
                                          ],
                                          categoriesByView: [
                                            TPPBPolicyCategoriesByView(view: "Home", categories: ["full", "watch", "tv", "audio"]),
                                            TPPBPolicyCategoriesByView(view: "ProtectedCloudStorage", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "Passwords", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "SecureObjectSync", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "WiFi", categories: ["full", "watch", "tv", "audio"]),
                                            TPPBPolicyCategoriesByView(view: "CreditCards", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "ApplePay", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "Health", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "AutoUnlock", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "LimitedPeersAllowed", categories: ["full", "watch", "tv", "audio"]),
                                            TPPBPolicyCategoriesByView(view: "DevicePairing", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "Manatee", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "Engram", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "Backstop", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "Applications", categories: ["full", "watch"]),
                                          ],
                                          introducersByCategory: [
                                            TPPBPolicyIntroducersByCategory(category: "full", introducers: ["full", "watch"]),
                                            TPPBPolicyIntroducersByCategory(category: "tv", introducers: ["full", "watch", "tv"]),
                                            TPPBPolicyIntroducersByCategory(category: "watch", introducers: ["full", "watch"]),
                                            TPPBPolicyIntroducersByCategory(category: "audio", introducers: ["full", "watch", "audio"]),
                                          ],
                                          redactions: [],
                                          keyViewMapping: [
                                            TPPBPolicyKeyViewMapping(view: "ApplePay", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^ApplePay$")),
                                            TPPBPolicyKeyViewMapping(view: "AutoUnlock", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^AutoUnlock$")),
                                            TPPBPolicyKeyViewMapping(view: "Engram", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^Engram$")),
                                            TPPBPolicyKeyViewMapping(view: "Health", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^Health$")),
                                            TPPBPolicyKeyViewMapping(view: "Home", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^Home$")),
                                            TPPBPolicyKeyViewMapping(view: "Manatee", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^Manatee$")),
                                            TPPBPolicyKeyViewMapping(view: "LimitedPeersAllowed", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^LimitedPeersAllowed$")),

                                            // These items will not be synced by Octagon
                                            TPPBPolicyKeyViewMapping(view: "NotSynced", matchingRule:
                                                                        TPDictionaryMatchingRule.orMatch([
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^ContinuityUnlock$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^HomeKit$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^AppleTV$"),
                                                                        ])),

                                            TPPBPolicyKeyViewMapping(view: "Applications", matchingRule:
                                                                        TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^[0-9A-Z]{10}\\.")),

                                            TPPBPolicyKeyViewMapping(view: "SecureObjectSync", matchingRule:
                                                                        TPDictionaryMatchingRule.orMatch([
                                                                            TPDictionaryMatchingRule.andMatch([
                                                                                TPDictionaryMatchingRule.fieldMatch("class", fieldRegex: "^genp$"),
                                                                                TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com\\.apple\\.sbd$"),
                                                                            ]),
                                                                            TPDictionaryMatchingRule.andMatch([
                                                                                TPDictionaryMatchingRule.fieldMatch("class", fieldRegex: "^keys$"),
                                                                                TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com\\.apple\\.security\\.sos$"),
                                                                            ]),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^BackupBagV0$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^iCloudIdentity$"),
                                                                        ])),

                                            TPPBPolicyKeyViewMapping(view: "WiFi", matchingRule:
                                                                        TPDictionaryMatchingRule.orMatch([
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^WiFi$"),
                                                                            TPDictionaryMatchingRule.andMatch([
                                                                                TPDictionaryMatchingRule.fieldMatch("class", fieldRegex: "^genp$"),
                                                                                TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^apple$"),
                                                                                TPDictionaryMatchingRule.fieldMatch("svce", fieldRegex: "^AirPort$"),
                                                                            ]),
                                                                        ])),

                                            TPPBPolicyKeyViewMapping(view: "ProtectedCloudStorage", matchingRule:
                                                                        TPDictionaryMatchingRule.orMatch([
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-Backup$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-CloudKit$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-Escrow$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-FDE$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-Feldspar$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-MailDrop$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-Maildrop$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-MasterKey$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-Notes$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-Photos$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-Sharing$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-iCloudBackup$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-iCloudDrive$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-iMessage$"),
                                                                        ])),

                                            TPPBPolicyKeyViewMapping(view: "CreditCards",
                                                                     matchingRule: TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com\\.apple\\.safari\\.credit-cards$")),

                                            TPPBPolicyKeyViewMapping(view: "Passwords",
                                                                     matchingRule: TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com\\.apple\\.cfnetwork$")),

                                            TPPBPolicyKeyViewMapping(view: "DevicePairing", matchingRule:
                                                                        TPDictionaryMatchingRule.orMatch([
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^AccessoryPairing$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^NanoRegistry$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^WatchMigration$"),
                                                                        ])),

                                            TPPBPolicyKeyViewMapping(view: "Backstop", matchingRule:
                                                                        TPDictionaryMatchingRule.trueMatch()),
                                          ],
                                          userControllableViewList: [],
                                          piggybackViews: [],
                                          priorityViews: [],
                                          inheritedExcludedViews: [],
                                          hashAlgo: .SHA256)}),

    RawPolicy(
        version: TPPolicyVersion(version: 8, hash: "SHA256:TeQdvkO5GhKk6ayq004RlKDspusM8keCq3sXvKlmp7g="),
        policyData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QKDl5QQ1MtTWFpbGRyb3AkEhsABCIXAgR2d2h0Cg9eUENTLU1hc3RlcktleSQSFwAEIhMCBHZ3aHQKC15QQ1MtTm90ZXMkEhgABCIUAgR2d2h0CgxeUENTLVBob3RvcyQSGQAEIhUCBHZ3aHQKDV5QQ1MtU2hhcmluZyQSHgAEIhoCBHZ3aHQKEl5QQ1MtaUNsb3VkQmFja3VwJBIdAAQiGQIEdndodAoRXlBDUy1pQ2xvdWREcml2ZSQSGgAEIhYCBHZ3aHQKDl5QQ1MtaU1lc3NhZ2UkEhVQcm90ZWN0ZWRDbG91ZFN0b3JhZ2UyXApNAAISLgAEIioCBGFncnAKIl5jb21cLmFwcGxlXC5zYWZhcmlcLmNyZWRpdC1jYXJkcyQSGQAEIhUCBHZ3aHQKDV5DcmVkaXRDYXJkcyQSC0NyZWRpdENhcmRzMqYBCpgBAAISIwAEIh8CBGFncnAKF15jb21cLmFwcGxlXC5jZm5ldHdvcmskEioABCImAgRhZ3JwCh5eY29tXC5hcHBsZVwucGFzc3dvcmQtbWFuYWdlciQSKgAEIiYCBGFncnAKHl5jb21cLmFwcGxlXC5XZWJLaXRcLldlYkF1dGhuJBIXAAQiEwIEdndodAoLXlBhc3N3b3JkcyQSCVBhc3N3b3JkczJtClwAAhIeAAQiGgIEdndodAoSXkFjY2Vzc29yeVBhaXJpbmckEhoABCIWAgR2d2h0Cg5eTmFub1JlZ2lzdHJ5JBIcAAQiGAIEdndodAoQXldhdGNoTWlncmF0aW9uJBINRGV2aWNlUGFpcmluZzIOCgIABhIIQmFja3N0b3A6DEFwcGxpY2F0aW9uczoIQmFja3N0b3A6C0NyZWRpdENhcmRzOglQYXNzd29yZHM6BFdpRmlCCVBhc3N3b3Jkcw==" },
        plaintextPolicy: {TPPolicyDocument(version: 8,
                                          modelToCategory: [
                                            TPPBPolicyModelToCategory(prefix: "iPhone", category: "full"),
                                            TPPBPolicyModelToCategory(prefix: "iPad", category: "full"),
                                            TPPBPolicyModelToCategory(prefix: "iPod", category: "full"),
                                            TPPBPolicyModelToCategory(prefix: "Mac", category: "full"),
                                            TPPBPolicyModelToCategory(prefix: "iMac", category: "full"),
                                            TPPBPolicyModelToCategory(prefix: "AppleTV", category: "tv"),
                                            TPPBPolicyModelToCategory(prefix: "Watch", category: "watch"),
                                            TPPBPolicyModelToCategory(prefix: "AudioAccessory", category: "audio"),
                                          ],
                                          categoriesByView: [
                                            TPPBPolicyCategoriesByView(view: "Applications", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "ProtectedCloudStorage", categories: ["full", "watch", "tv", "audio"]),
                                            TPPBPolicyCategoriesByView(view: "Passwords", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "Backstop", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "WiFi", categories: ["full", "watch", "tv", "audio"]),
                                            TPPBPolicyCategoriesByView(view: "SecureObjectSync", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "ApplePay", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "Health", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "AutoUnlock", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "LimitedPeersAllowed", categories: ["full", "watch", "tv", "audio"]),
                                            TPPBPolicyCategoriesByView(view: "DevicePairing", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "Manatee", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "Engram", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "Home", categories: ["full", "watch", "tv", "audio"]),
                                            TPPBPolicyCategoriesByView(view: "CreditCards", categories: ["full", "watch"]),
                                          ],
                                          introducersByCategory: [
                                            TPPBPolicyIntroducersByCategory(category: "full", introducers: ["full", "watch"]),
                                            TPPBPolicyIntroducersByCategory(category: "watch", introducers: ["full", "watch"]),
                                            TPPBPolicyIntroducersByCategory(category: "audio", introducers: ["full", "watch", "audio"]),
                                            TPPBPolicyIntroducersByCategory(category: "tv", introducers: ["full", "watch", "tv"]),
                                          ],
                                          redactions: [],
                                          keyViewMapping: [
                                            TPPBPolicyKeyViewMapping(view: "ApplePay", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^ApplePay$")),
                                            TPPBPolicyKeyViewMapping(view: "AutoUnlock", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^AutoUnlock$")),
                                            TPPBPolicyKeyViewMapping(view: "Engram", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^Engram$")),
                                            TPPBPolicyKeyViewMapping(view: "Health", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^Health$")),
                                            TPPBPolicyKeyViewMapping(view: "Home", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^Home$")),
                                            TPPBPolicyKeyViewMapping(view: "Manatee", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^Manatee$")),
                                            TPPBPolicyKeyViewMapping(view: "LimitedPeersAllowed", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^LimitedPeersAllowed$")),

                                            // These items will not be synced by Octagon
                                            TPPBPolicyKeyViewMapping(view: "NotSynced", matchingRule:
                                                                        TPDictionaryMatchingRule.orMatch([
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^ContinuityUnlock$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^HomeKit$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^AppleTV$"),
                                                                        ])),

                                            TPPBPolicyKeyViewMapping(view: "Applications", matchingRule:
                                                                        TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^[0-9A-Z]{10}\\.")),

                                            TPPBPolicyKeyViewMapping(view: "SecureObjectSync", matchingRule:
                                                                        TPDictionaryMatchingRule.orMatch([
                                                                            TPDictionaryMatchingRule.andMatch([
                                                                                TPDictionaryMatchingRule.fieldMatch("class", fieldRegex: "^genp$"),
                                                                                TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com\\.apple\\.sbd$"),
                                                                            ]),
                                                                            TPDictionaryMatchingRule.andMatch([
                                                                                TPDictionaryMatchingRule.fieldMatch("class", fieldRegex: "^keys$"),
                                                                                TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com\\.apple\\.security\\.sos$"),
                                                                            ]),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^BackupBagV0$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^iCloudIdentity$"),
                                                                        ])),

                                            TPPBPolicyKeyViewMapping(view: "WiFi", matchingRule:
                                                                        TPDictionaryMatchingRule.orMatch([
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^WiFi$"),
                                                                            TPDictionaryMatchingRule.andMatch([
                                                                                TPDictionaryMatchingRule.fieldMatch("class", fieldRegex: "^genp$"),
                                                                                TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^apple$"),
                                                                                TPDictionaryMatchingRule.fieldMatch("svce", fieldRegex: "^AirPort$"),
                                                                            ]),
                                                                        ])),

                                            TPPBPolicyKeyViewMapping(view: "ProtectedCloudStorage", matchingRule:
                                                                        TPDictionaryMatchingRule.orMatch([
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-Backup$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-CloudKit$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-Escrow$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-FDE$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-Feldspar$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-MailDrop$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-Maildrop$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-MasterKey$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-Notes$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-Photos$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-Sharing$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-iCloudBackup$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-iCloudDrive$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-iMessage$"),
                                                                        ])),

                                            TPPBPolicyKeyViewMapping(view: "CreditCards", matchingRule:
                                                                        TPDictionaryMatchingRule.orMatch([
                                                                            TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com\\.apple\\.safari\\.credit-cards$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^CreditCards$"),
                                                                        ])),

                                            TPPBPolicyKeyViewMapping(view: "Passwords", matchingRule:
                                                                        TPDictionaryMatchingRule.orMatch([
                                                                            TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com\\.apple\\.cfnetwork$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com\\.apple\\.password-manager$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com\\.apple\\.WebKit\\.WebAuthn$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^Passwords$"),
                                                                        ])),

                                            TPPBPolicyKeyViewMapping(view: "DevicePairing", matchingRule:
                                                                        TPDictionaryMatchingRule.orMatch([
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^AccessoryPairing$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^NanoRegistry$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^WatchMigration$"),
                                                                        ])),

                                            TPPBPolicyKeyViewMapping(view: "Backstop", matchingRule:
                                                                        TPDictionaryMatchingRule.trueMatch()),
                                          ],
                                          userControllableViewList: [
                                            "Applications",
                                            "Backstop",
                                            "CreditCards",
                                            "Passwords",
                                            "WiFi",
                                          ],
                                          piggybackViews: [
                                            "Passwords",
                                          ],
                                          priorityViews: [],
                                          inheritedExcludedViews: [],
                                          hashAlgo: .SHA256)}),

    RawPolicy(
        version: TPPolicyVersion(version: 9, hash: "SHA256:uynvb6IWdFbCM2AQX0aKv0yUMLg8Z2wZjZY5k4jtAj8="),
        policyData: { "CAkSDgoGaVBob25lEgRmdWxsEgwKBGlQYWQSBGZ1bGwSDAoEaVBvZBIEZnVsbBILCgNNYWMSBGZ1bGwSDAoEaU1hYxIEZnVsbBINCgdBcHBsZVRWEgJ0dhIOCgVXYXRjaBIFd2F0Y2gSFwoOQXVkaW9BY2Nlc3NvcnkSBWF1ZGlvGh4KBEhvbWUSBGZ1bGwSBXdhdGNoEgJ0dhIFYXVkaW8aLwoVUHJvdGVjdGVkQ2xvdWRTdG9yYWdlEgRmdWxsEgV3YXRjaBICdHYSBWF1ZGlvGhgKCVBhc3N3b3JkcxIEZnVsbBIFd2F0Y2gaHwoQU2VjdXJlT2JqZWN0U3luYxIEZnVsbBIFd2F0Y2gaHgoEV2lGaRIEZnVsbBIFd2F0Y2gSAnR2EgVhdWRpbxobCgxBcHBsaWNhdGlvbnMSBGZ1bGwSBXdhdGNoGhcKCEFwcGxlUGF5EgRmdWxsEgV3YXRjaBoVCgZIZWFsdGgSBGZ1bGwSBXdhdGNoGhkKCkF1dG9VbmxvY2sSBGZ1bGwSBXdhdGNoGi0KE0xpbWl0ZWRQZWVyc0FsbG93ZWQSBGZ1bGwSBXdhdGNoEgJ0dhIFYXVkaW8aHAoNRGV2aWNlUGFpc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bGVcLndlYmtpdFwud2ViYXV0aG4kEhcABCITAgR2d2h0CgteUGFzc3dvcmRzJBIJUGFzc3dvcmRzMm0KXAACEh4ABCIaAgR2d2h0ChJeQWNjZXNzb3J5UGFpcmluZyQSGgAEIhYCBHZ3aHQKDl5OYW5vUmVnaXN0cnkkEhwABCIYAgR2d2h0ChBeV2F0Y2hNaWdyYXRpb24kEg1EZXZpY2VQYWlyaW5nMg4KAgAGEghCYWNrc3RvcDoMQXBwbGljYXRpb25zOghCYWNrc3RvcDoLQ3JlZGl0Q2FyZHM6CVBhc3N3b3JkczoEV2lGaUIJUGFzc3dvcmRzShVQcm90ZWN0ZWRDbG91ZFN0b3JhZ2VKEFNlY3VyZU9iamVjdFN5bmM=" },
        plaintextPolicy: {TPPolicyDocument(version: 9,
                                          modelToCategory: [
                                            TPPBPolicyModelToCategory(prefix: "iPhone", category: "full"),
                                            TPPBPolicyModelToCategory(prefix: "iPad", category: "full"),
                                            TPPBPolicyModelToCategory(prefix: "iPod", category: "full"),
                                            TPPBPolicyModelToCategory(prefix: "Mac", category: "full"),
                                            TPPBPolicyModelToCategory(prefix: "iMac", category: "full"),
                                            TPPBPolicyModelToCategory(prefix: "AppleTV", category: "tv"),
                                            TPPBPolicyModelToCategory(prefix: "Watch", category: "watch"),
                                            TPPBPolicyModelToCategory(prefix: "AudioAccessory", category: "audio"),
                                          ],
                                          categoriesByView: [
                                            TPPBPolicyCategoriesByView(view: "Home", categories: ["full", "watch", "tv", "audio"]),
                                            TPPBPolicyCategoriesByView(view: "ProtectedCloudStorage", categories: ["full", "watch", "tv", "audio"]),
                                            TPPBPolicyCategoriesByView(view: "Passwords", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "SecureObjectSync", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "WiFi", categories: ["full", "watch", "tv", "audio"]),
                                            TPPBPolicyCategoriesByView(view: "Applications", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "ApplePay", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "Health", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "AutoUnlock", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "LimitedPeersAllowed", categories: ["full", "watch", "tv", "audio"]),
                                            TPPBPolicyCategoriesByView(view: "DevicePairing", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "Manatee", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "Engram", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "Backstop", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "CreditCards", categories: ["full", "watch"]),
                                          ],
                                          introducersByCategory: [
                                            TPPBPolicyIntroducersByCategory(category: "full", introducers: ["full", "watch"]),
                                            TPPBPolicyIntroducersByCategory(category: "audio", introducers: ["full", "watch", "audio"]),
                                            TPPBPolicyIntroducersByCategory(category: "tv", introducers: ["full", "watch", "tv"]),
                                            TPPBPolicyIntroducersByCategory(category: "watch", introducers: ["full", "watch"]),
                                          ],
                                          redactions: [],
                                          keyViewMapping: [
                                            TPPBPolicyKeyViewMapping(view: "ApplePay", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^ApplePay$")),
                                            TPPBPolicyKeyViewMapping(view: "AutoUnlock", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^AutoUnlock$")),
                                            TPPBPolicyKeyViewMapping(view: "Engram", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^Engram$")),
                                            TPPBPolicyKeyViewMapping(view: "Health", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^Health$")),
                                            TPPBPolicyKeyViewMapping(view: "Home", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^Home$")),
                                            TPPBPolicyKeyViewMapping(view: "Manatee", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^Manatee$")),
                                            TPPBPolicyKeyViewMapping(view: "LimitedPeersAllowed", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^LimitedPeersAllowed$")),

                                            // These items will not be synced by Octagon
                                            TPPBPolicyKeyViewMapping(view: "NotSynced", matchingRule:
                                                                        TPDictionaryMatchingRule.orMatch([
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^ContinuityUnlock$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^HomeKit$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^AppleTV$"),
                                                                        ])),

                                            TPPBPolicyKeyViewMapping(view: "Applications", matchingRule:
                                                                        TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^[0-9A-Z]{10}\\.")),

                                            TPPBPolicyKeyViewMapping(view: "SecureObjectSync", matchingRule:
                                                                        TPDictionaryMatchingRule.orMatch([
                                                                            TPDictionaryMatchingRule.andMatch([
                                                                                TPDictionaryMatchingRule.fieldMatch("class", fieldRegex: "^genp$"),
                                                                                TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com\\.apple\\.sbd$"),
                                                                            ]),
                                                                            TPDictionaryMatchingRule.andMatch([
                                                                                TPDictionaryMatchingRule.fieldMatch("class", fieldRegex: "^keys$"),
                                                                                TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com\\.apple\\.security\\.sos$"),
                                                                            ]),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^BackupBagV0$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^iCloudIdentity$"),
                                                                        ])),

                                            TPPBPolicyKeyViewMapping(view: "WiFi", matchingRule:
                                                                        TPDictionaryMatchingRule.orMatch([
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^WiFi$"),
                                                                            TPDictionaryMatchingRule.andMatch([
                                                                                TPDictionaryMatchingRule.fieldMatch("class", fieldRegex: "^genp$"),
                                                                                TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^apple$"),
                                                                                TPDictionaryMatchingRule.fieldMatch("svce", fieldRegex: "^AirPort$"),
                                                                            ]),
                                                                        ])),

                                            TPPBPolicyKeyViewMapping(view: "ProtectedCloudStorage", matchingRule:
                                                                        TPDictionaryMatchingRule.orMatch([
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-Backup$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-CloudKit$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-Escrow$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-FDE$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-Feldspar$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-MailDrop$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-Maildrop$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-MasterKey$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-Notes$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-Photos$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-Sharing$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-iCloudBackup$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-iCloudDrive$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-iMessage$"),
                                                                        ])),

                                            TPPBPolicyKeyViewMapping(view: "CreditCards", matchingRule:
                                                                        TPDictionaryMatchingRule.orMatch([
                                                                            TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com\\.apple\\.safari\\.credit-cards$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^CreditCards$"),
                                                                        ])),

                                            TPPBPolicyKeyViewMapping(view: "Passwords", matchingRule:
                                                                        TPDictionaryMatchingRule.orMatch([
                                                                            TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com\\.apple\\.cfnetwork$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com\\.apple\\.password-manager$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com\\.apple\\.WebKit\\.WebAuthn$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com\\.apple\\.webkit\\.webauthn$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^Passwords$"),
                                                                        ])),

                                            TPPBPolicyKeyViewMapping(view: "DevicePairing", matchingRule:
                                                                        TPDictionaryMatchingRule.orMatch([
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^AccessoryPairing$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^NanoRegistry$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^WatchMigration$"),
                                                                        ])),

                                            TPPBPolicyKeyViewMapping(view: "Backstop", matchingRule:
                                                                        TPDictionaryMatchingRule.trueMatch()),
                                          ],
                                          userControllableViewList: [
                                            "Applications",
                                            "Backstop",
                                            "CreditCards",
                                            "Passwords",
                                            "WiFi",
                                          ],
                                          piggybackViews: [
                                            "Passwords",
                                          ],
                                          priorityViews: [
                                            "ProtectedCloudStorage",
                                            "SecureObjectSync",
                                          ],
                                          inheritedExcludedViews: [],
                                          hashAlgo: .SHA256)}),

    RawPolicy(
        version: TPPolicyVersion(version: 10, hash: "SHA256:KOpJ0KvNFWPNJpDTVQwRRP30fm3zhvDQznROVmAKtJY="),
        policyData: { "CAoSDgoGaVBob25lEgRmdWxsEgw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WN0ZWRDbG91ZFN0b3JhZ2VKEFNlY3VyZU9iamVjdFN5bmM=" },
        plaintextPolicy: {TPPolicyDocument(version: 10,
                                          modelToCategory: [
                                            TPPBPolicyModelToCategory(prefix: "iPhone", category: "full"),
                                            TPPBPolicyModelToCategory(prefix: "iPad", category: "full"),
                                            TPPBPolicyModelToCategory(prefix: "iPod", category: "full"),
                                            TPPBPolicyModelToCategory(prefix: "Mac", category: "full"),
                                            TPPBPolicyModelToCategory(prefix: "iMac", category: "full"),
                                            TPPBPolicyModelToCategory(prefix: "AppleTV", category: "tv"),
                                            TPPBPolicyModelToCategory(prefix: "Watch", category: "watch"),
                                            TPPBPolicyModelToCategory(prefix: "AudioAccessory", category: "audio"),
                                            TPPBPolicyModelToCategory(prefix: "WinPC", category: "windows"),
                                          ],
                                          categoriesByView: [
                                            TPPBPolicyCategoriesByView(view: "Applications", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "ProtectedCloudStorage", categories: [ "windows", "full", "watch", "tv", "audio"]),
                                            TPPBPolicyCategoriesByView(view: "Passwords", categories: ["full", "watch", "windows"]),
                                            TPPBPolicyCategoriesByView(view: "SecureObjectSync", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "WiFi", categories: ["full", "watch", "tv", "audio"]),
                                            TPPBPolicyCategoriesByView(view: "Backstop", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "ApplePay", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "AutoUnlock", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "Health", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "LimitedPeersAllowed", categories: ["windows", "full", "watch", "tv", "audio"]),
                                            TPPBPolicyCategoriesByView(view: "DevicePairing", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "Manatee", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "Engram", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "Home", categories: ["full", "watch", "tv", "audio"]),
                                            TPPBPolicyCategoriesByView(view: "CreditCards", categories: ["full", "watch"]),
                                          ],
                                          introducersByCategory: [
                                            TPPBPolicyIntroducersByCategory(category: "windows", introducers: ["full", "watch"]),
                                            TPPBPolicyIntroducersByCategory(category: "full", introducers: ["full", "watch"]),
                                            TPPBPolicyIntroducersByCategory(category: "tv", introducers: ["full", "watch", "tv"]),
                                            TPPBPolicyIntroducersByCategory(category: "audio", introducers: ["full", "watch", "audio"]),
                                            TPPBPolicyIntroducersByCategory(category: "watch", introducers: ["full", "watch"]),
                                          ],
                                          redactions: [],
                                          keyViewMapping: [
                                            TPPBPolicyKeyViewMapping(view: "ApplePay", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^ApplePay$")),
                                            TPPBPolicyKeyViewMapping(view: "AutoUnlock", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^AutoUnlock$")),
                                            TPPBPolicyKeyViewMapping(view: "Engram", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^Engram$")),
                                            TPPBPolicyKeyViewMapping(view: "Health", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^Health$")),
                                            TPPBPolicyKeyViewMapping(view: "Home", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^Home$")),
                                            TPPBPolicyKeyViewMapping(view: "Manatee", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^Manatee$")),
                                            TPPBPolicyKeyViewMapping(view: "LimitedPeersAllowed", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^LimitedPeersAllowed$")),

                                            // These items will not be synced by Octagon
                                            TPPBPolicyKeyViewMapping(view: "NotSynced", matchingRule:
                                                                        TPDictionaryMatchingRule.orMatch([
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^ContinuityUnlock$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^HomeKit$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^AppleTV$"),
                                                                        ])),

                                            TPPBPolicyKeyViewMapping(view: "Applications", matchingRule:
                                                                        TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^[0-9A-Z]{10}\\.")),

                                            TPPBPolicyKeyViewMapping(view: "SecureObjectSync", matchingRule:
                                                                        TPDictionaryMatchingRule.orMatch([
                                                                            TPDictionaryMatchingRule.andMatch([
                                                                                TPDictionaryMatchingRule.fieldMatch("class", fieldRegex: "^genp$"),
                                                                                TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com\\.apple\\.sbd$"),
                                                                            ]),
                                                                            TPDictionaryMatchingRule.andMatch([
                                                                                TPDictionaryMatchingRule.fieldMatch("class", fieldRegex: "^keys$"),
                                                                                TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com\\.apple\\.security\\.sos$"),
                                                                            ]),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^BackupBagV0$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^iCloudIdentity$"),
                                                                        ])),

                                            TPPBPolicyKeyViewMapping(view: "WiFi", matchingRule:
                                                                        TPDictionaryMatchingRule.orMatch([
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^WiFi$"),
                                                                            TPDictionaryMatchingRule.andMatch([
                                                                                TPDictionaryMatchingRule.fieldMatch("class", fieldRegex: "^genp$"),
                                                                                TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^apple$"),
                                                                                TPDictionaryMatchingRule.fieldMatch("svce", fieldRegex: "^AirPort$"),
                                                                            ]),
                                                                        ])),

                                            TPPBPolicyKeyViewMapping(view: "ProtectedCloudStorage", matchingRule:
                                                                        TPDictionaryMatchingRule.orMatch([
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-Backup$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-CloudKit$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-Escrow$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-FDE$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-Feldspar$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-MailDrop$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-Maildrop$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-MasterKey$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-Notes$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-Photos$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-Sharing$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-iCloudBackup$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-iCloudDrive$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-iMessage$"),
                                                                        ])),

                                            TPPBPolicyKeyViewMapping(view: "CreditCards", matchingRule:
                                                                        TPDictionaryMatchingRule.orMatch([
                                                                            TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com\\.apple\\.safari\\.credit-cards$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^CreditCards$"),
                                                                        ])),

                                            TPPBPolicyKeyViewMapping(view: "Passwords", matchingRule:
                                                                        TPDictionaryMatchingRule.orMatch([
                                                                            TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com\\.apple\\.cfnetwork$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com\\.apple\\.password-manager$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com\\.apple\\.WebKit\\.WebAuthn$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com\\.apple\\.webkit\\.webauthn$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^Passwords$"),
                                                                        ])),

                                            TPPBPolicyKeyViewMapping(view: "DevicePairing", matchingRule:
                                                                        TPDictionaryMatchingRule.orMatch([
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^AccessoryPairing$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^NanoRegistry$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^WatchMigration$"),
                                                                        ])),

                                            TPPBPolicyKeyViewMapping(view: "Backstop", matchingRule:
                                                                        TPDictionaryMatchingRule.trueMatch()),
                                          ],
                                          userControllableViewList: [
                                            "Applications",
                                            "Backstop",
                                            "CreditCards",
                                            "Passwords",
                                            "WiFi",
                                          ],
                                          piggybackViews: [
                                            "Passwords",
                                          ],
                                          priorityViews: [
                                            "ProtectedCloudStorage",
                                            "SecureObjectSync",
                                          ],
                                          inheritedExcludedViews: [],
                                          hashAlgo: .SHA256)}),

    RawPolicy(
        version: TPPolicyVersion(version: 11, hash: "SHA256:Cm1JV53DOukT+DcNYpkbTc8+rH3cAb/1Cop6Zn7PC28="),
        policyData: { "CAsSDgoGaVBob25lEgRmdWxsEgwKBGlQYWQSBGZ1bGwSDAoEaVBvZBIEZnVsbBILCgNNYWMSBGZ1bGwSDAoEaU1hYxIEZnVsbBINCgdBcHBsZVRWEgJ0dhIOCgVXYXRjaBIFd2F0Y2gSFwoOQXVkaW9BY2Nlc3NvcnkSBWF1ZGlvEhAKBVdpblBDEgd3aW5kb3dzGhsKDEFwcGxpY2F0aW9ucxIEZnVsbBIFd2F0Y2gaOAoVUHJvdGVjdGVkQ2xvdWRT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b3MkEhkABCIVAgR2d2h0Cg1eUENTLVNoYXJpbmckEh4ABCIaAgR2d2h0ChJeUENTLWlDbG91ZEJhY2t1cCQSHQAEIhkCBHZ3aHQKEV5QQ1MtaUNsb3VkRHJpdmUkEhoABCIWAgR2d2h0Cg5eUENTLWlNZXNzYWdlJBIVUHJvdGVjdGVkQ2xvdWRTdG9yYWdlMlwKTQACEi4ABCIqAgRhZ3JwCiJeY29tXC5hcHBsZVwuc2FmYXJpXC5jcmVkaXQtY2FyZHMkEhkABCIVAgR2d2h0Cg1eQ3JlZGl0Q2FyZHMkEgtDcmVkaXRDYXJkczLSAQrEAQACEiMABCIfAgRhZ3JwChdeY29tXC5hcHBsZVwuY2ZuZXR3b3JrJBIqAAQiJgIEYWdycAoeXmNvbVwuYXBwbGVcLnBhc3N3b3JkLW1hbmFnZXIkEioABCImAgRhZ3JwCh5eY29tXC5hcHBsZVwuV2ViS2l0XC5XZWJBdXRobiQSKgAEIiYCBGFncnAKHl5jb21cLmFwcGxlXC53ZWJraXRcLndlYmF1dGhuJBIXAAQiEwIEdndodAoLXlBhc3N3b3JkcyQSCVBhc3N3b3JkczJtClwAAhIeAAQiGgIEdndodAoSXkFjY2Vzc29yeVBhaXJpbmckEhoABCIWAgR2d2h0Cg5eTmFub1JlZ2lzdHJ5JBIcAAQiGAIEdndodAoQXldhdGNoTWlncmF0aW9uJBINRGV2aWNlUGFpcmluZzIOCgIABhIIQmFja3N0b3A6DEFwcGxpY2F0aW9uczoIQmFja3N0b3A6C0NyZWRpdENhcmRzOglQYXNzd29yZHM6BFdpRmlCCVBhc3N3b3Jkc0oVUHJvdGVjdGVkQ2xvdWRTdG9yYWdlShBTZWN1cmVPYmplY3RTeW5j" },
        plaintextPolicy: {TPPolicyDocument(version: 11,
                                          modelToCategory: [
                                            TPPBPolicyModelToCategory(prefix: "iPhone", category: "full"),
                                            TPPBPolicyModelToCategory(prefix: "iPad", category: "full"),
                                            TPPBPolicyModelToCategory(prefix: "iPod", category: "full"),
                                            TPPBPolicyModelToCategory(prefix: "Mac", category: "full"),
                                            TPPBPolicyModelToCategory(prefix: "iMac", category: "full"),
                                            TPPBPolicyModelToCategory(prefix: "AppleTV", category: "tv"),
                                            TPPBPolicyModelToCategory(prefix: "Watch", category: "watch"),
                                            TPPBPolicyModelToCategory(prefix: "AudioAccessory", category: "audio"),
                                            TPPBPolicyModelToCategory(prefix: "WinPC", category: "windows"),
                                          ],
                                          categoriesByView: [
                                            TPPBPolicyCategoriesByView(view: "Applications", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "ProtectedCloudStorage", categories: [ "windows", "full", "watch", "tv", "audio"]),
                                            TPPBPolicyCategoriesByView(view: "Passwords", categories: ["full", "watch", "windows"]),
                                            TPPBPolicyCategoriesByView(view: "Home", categories: ["full", "watch", "tv", "audio"]),
                                            TPPBPolicyCategoriesByView(view: "WiFi", categories: ["full", "watch", "tv", "audio"]),
                                            TPPBPolicyCategoriesByView(view: "SecureObjectSync", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "ApplePay", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "AutoUnlock", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "Health", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "LimitedPeersAllowed", categories: ["windows", "full", "watch", "tv", "audio"]),
                                            TPPBPolicyCategoriesByView(view: "DevicePairing", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "Manatee", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "Engram", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "MFi", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "Backstop", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "CreditCards", categories: ["full", "watch"]),
                                          ],
                                          introducersByCategory: [
                                            TPPBPolicyIntroducersByCategory(category: "windows", introducers: ["full", "watch"]),
                                            TPPBPolicyIntroducersByCategory(category: "full", introducers: ["full", "watch"]),
                                            TPPBPolicyIntroducersByCategory(category: "watch", introducers: ["full", "watch"]),
                                            TPPBPolicyIntroducersByCategory(category: "tv", introducers: ["full", "watch", "tv"]),
                                            TPPBPolicyIntroducersByCategory(category: "audio", introducers: ["full", "watch", "audio"]),
                                          ],
                                          redactions: [],
                                          keyViewMapping: [
                                            TPPBPolicyKeyViewMapping(view: "ApplePay", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^ApplePay$")),
                                            TPPBPolicyKeyViewMapping(view: "AutoUnlock", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^AutoUnlock$")),
                                            TPPBPolicyKeyViewMapping(view: "Engram", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^Engram$")),
                                            TPPBPolicyKeyViewMapping(view: "Health", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^Health$")),
                                            TPPBPolicyKeyViewMapping(view: "Home", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^Home$")),
                                            TPPBPolicyKeyViewMapping(view: "Manatee", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^Manatee$")),
                                            TPPBPolicyKeyViewMapping(view: "LimitedPeersAllowed", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^LimitedPeersAllowed$")),

                                            // These items will not be synced by Octagon
                                            TPPBPolicyKeyViewMapping(view: "NotSynced", matchingRule:
                                                                        TPDictionaryMatchingRule.orMatch([
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^ContinuityUnlock$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^HomeKit$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^AppleTV$"),
                                                                        ])),

                                            TPPBPolicyKeyViewMapping(view: "MFi", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^MFi$")),

                                            TPPBPolicyKeyViewMapping(view: "Applications", matchingRule:
                                                                        TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^[0-9A-Z]{10}\\.")),

                                            TPPBPolicyKeyViewMapping(view: "SecureObjectSync", matchingRule:
                                                                        TPDictionaryMatchingRule.orMatch([
                                                                            TPDictionaryMatchingRule.andMatch([
                                                                                TPDictionaryMatchingRule.fieldMatch("class", fieldRegex: "^genp$"),
                                                                                TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com\\.apple\\.sbd$"),
                                                                            ]),
                                                                            TPDictionaryMatchingRule.andMatch([
                                                                                TPDictionaryMatchingRule.fieldMatch("class", fieldRegex: "^keys$"),
                                                                                TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com\\.apple\\.security\\.sos$"),
                                                                            ]),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^BackupBagV0$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^iCloudIdentity$"),
                                                                        ])),

                                            TPPBPolicyKeyViewMapping(view: "WiFi", matchingRule:
                                                                        TPDictionaryMatchingRule.orMatch([
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^WiFi$"),
                                                                            TPDictionaryMatchingRule.andMatch([
                                                                                TPDictionaryMatchingRule.fieldMatch("class", fieldRegex: "^genp$"),
                                                                                TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^apple$"),
                                                                                TPDictionaryMatchingRule.fieldMatch("svce", fieldRegex: "^AirPort$"),
                                                                            ]),
                                                                        ])),

                                            TPPBPolicyKeyViewMapping(view: "ProtectedCloudStorage", matchingRule:
                                                                        TPDictionaryMatchingRule.orMatch([
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-Backup$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-CloudKit$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-Escrow$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-FDE$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-Feldspar$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-MailDrop$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-Maildrop$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-MasterKey$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-Notes$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-Photos$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-Sharing$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-iCloudBackup$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-iCloudDrive$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-iMessage$"),
                                                                        ])),

                                            TPPBPolicyKeyViewMapping(view: "CreditCards", matchingRule:
                                                                        TPDictionaryMatchingRule.orMatch([
                                                                            TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com\\.apple\\.safari\\.credit-cards$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^CreditCards$"),
                                                                        ])),

                                            TPPBPolicyKeyViewMapping(view: "Passwords", matchingRule:
                                                                        TPDictionaryMatchingRule.orMatch([
                                                                            TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com\\.apple\\.cfnetwork$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com\\.apple\\.password-manager$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com\\.apple\\.WebKit\\.WebAuthn$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com\\.apple\\.webkit\\.webauthn$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^Passwords$"),
                                                                        ])),

                                            TPPBPolicyKeyViewMapping(view: "DevicePairing", matchingRule:
                                                                        TPDictionaryMatchingRule.orMatch([
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^AccessoryPairing$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^NanoRegistry$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^WatchMigration$"),
                                                                        ])),

                                            TPPBPolicyKeyViewMapping(view: "Backstop", matchingRule:
                                                                        TPDictionaryMatchingRule.trueMatch()),
                                          ],
                                          userControllableViewList: [
                                            "Applications",
                                            "Backstop",
                                            "CreditCards",
                                            "Passwords",
                                            "WiFi",
                                          ],
                                          piggybackViews: [
                                            "Passwords",
                                          ],
                                          priorityViews: [
                                            "ProtectedCloudStorage",
                                            "SecureObjectSync",
                                          ],
                                          inheritedExcludedViews: [],
                                          hashAlgo: .SHA256)}),

    // v12 keeps the order-independent lists in sorted order.

    RawPolicy(
        version: TPPolicyVersion(version: 12, hash: "SHA256:9Tb43EoxMTKvR1FTnPrWBKXf+Y20uaRdFa2TF6zR6xs="),
        policyData: { "CAwSDQoHQXBwbGVUVhICdHYSFwoOQXVkaW9BY2Nlc3NvcnkSBWF1ZGlvEgsKA01hYxIEZnVsbBIOCgVXYXRjaBIFd2F0Y2gSEAoFV2luUEMSB3dpbmRvd3MSDAoEaU1hYxIEZnVsbBIMCgRpUGFkEgRmdWxsEg4KBmlQaG9uZRIEZnVsbBIMCgRpUG9kEgRmdWxsGhcKCEFwcGxlUGF5EgRmdWxsEgV3YXRjaBobCgxBcHBsaWNhdGlvbnMSBGZ1bGwSBXdhdGNoGhkKCkF1dG9VbmxvY2sSBGZ1bGwSBXdhdGNoGhcKCEJhY2tz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0ChJeUENTLWlDbG91ZEJhY2t1cCQSHQAEIhkCBHZ3aHQKEV5QQ1MtaUNsb3VkRHJpdmUkEhoABCIWAgR2d2h0Cg5eUENTLWlNZXNzYWdlJBIVUHJvdGVjdGVkQ2xvdWRTdG9yYWdlMlwKTQACEi4ABCIqAgRhZ3JwCiJeY29tXC5hcHBsZVwuc2FmYXJpXC5jcmVkaXQtY2FyZHMkEhkABCIVAgR2d2h0Cg1eQ3JlZGl0Q2FyZHMkEgtDcmVkaXRDYXJkczLSAQrEAQACEiMABCIfAgRhZ3JwChdeY29tXC5hcHBsZVwuY2ZuZXR3b3JrJBIqAAQiJgIEYWdycAoeXmNvbVwuYXBwbGVcLnBhc3N3b3JkLW1hbmFnZXIkEioABCImAgRhZ3JwCh5eY29tXC5hcHBsZVwuV2ViS2l0XC5XZWJBdXRobiQSKgAEIiYCBGFncnAKHl5jb21cLmFwcGxlXC53ZWJraXRcLndlYmF1dGhuJBIXAAQiEwIEdndodAoLXlBhc3N3b3JkcyQSCVBhc3N3b3JkczJtClwAAhIeAAQiGgIEdndodAoSXkFjY2Vzc29yeVBhaXJpbmckEhoABCIWAgR2d2h0Cg5eTmFub1JlZ2lzdHJ5JBIcAAQiGAIEdndodAoQXldhdGNoTWlncmF0aW9uJBINRGV2aWNlUGFpcmluZzIOCgIABhIIQmFja3N0b3A6DEFwcGxpY2F0aW9uczoIQmFja3N0b3A6C0NyZWRpdENhcmRzOglQYXNzd29yZHM6BFdpRmlCCVBhc3N3b3Jkc0oVUHJvdGVjdGVkQ2xvdWRTdG9yYWdlShBTZWN1cmVPYmplY3RTeW5jUglQYXNzd29yZHM=" },
        plaintextPolicy: {TPPolicyDocument(version: 12,
                                          modelToCategory: [
                                            TPPBPolicyModelToCategory(prefix: "AppleTV", category: "tv"),
                                            TPPBPolicyModelToCategory(prefix: "AudioAccessory", category: "audio"),
                                            TPPBPolicyModelToCategory(prefix: "Mac", category: "full"),
                                            TPPBPolicyModelToCategory(prefix: "Watch", category: "watch"),
                                            TPPBPolicyModelToCategory(prefix: "WinPC", category: "windows"),
                                            TPPBPolicyModelToCategory(prefix: "iMac", category: "full"),
                                            TPPBPolicyModelToCategory(prefix: "iPad", category: "full"),
                                            TPPBPolicyModelToCategory(prefix: "iPhone", category: "full"),
                                            TPPBPolicyModelToCategory(prefix: "iPod", category: "full"),
                                          ],
                                          categoriesByView: [
                                            TPPBPolicyCategoriesByView(view: "ApplePay", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "Applications", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "AutoUnlock", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "Backstop", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "CreditCards", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "DevicePairing", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "Engram", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "Health", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "Home", categories: ["full", "watch", "tv", "audio"]),
                                            TPPBPolicyCategoriesByView(view: "LimitedPeersAllowed", categories: ["windows", "full", "watch", "tv", "audio"]),
                                            TPPBPolicyCategoriesByView(view: "MFi", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "Manatee", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "Passwords", categories: ["full", "watch", "windows"]),
                                            TPPBPolicyCategoriesByView(view: "ProtectedCloudStorage", categories: [ "windows", "full", "watch", "tv", "audio"]),
                                            TPPBPolicyCategoriesByView(view: "SecureObjectSync", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "WiFi", categories: ["full", "watch", "tv", "audio"]),
                                          ],
                                          introducersByCategory: [
                                            TPPBPolicyIntroducersByCategory(category: "audio", introducers: ["full", "watch", "audio"]),
                                            TPPBPolicyIntroducersByCategory(category: "full", introducers: ["full", "watch"]),
                                            TPPBPolicyIntroducersByCategory(category: "tv", introducers: ["full", "watch", "tv"]),
                                            TPPBPolicyIntroducersByCategory(category: "watch", introducers: ["full", "watch"]),
                                            TPPBPolicyIntroducersByCategory(category: "windows", introducers: ["full", "watch"]),
                                          ],
                                          redactions: [],
                                          keyViewMapping: [
                                            TPPBPolicyKeyViewMapping(view: "ApplePay", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^ApplePay$")),
                                            TPPBPolicyKeyViewMapping(view: "AutoUnlock", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^AutoUnlock$")),
                                            TPPBPolicyKeyViewMapping(view: "Engram", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^Engram$")),
                                            TPPBPolicyKeyViewMapping(view: "Health", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^Health$")),
                                            TPPBPolicyKeyViewMapping(view: "Home", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^Home$")),
                                            TPPBPolicyKeyViewMapping(view: "Manatee", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^Manatee$")),
                                            TPPBPolicyKeyViewMapping(view: "LimitedPeersAllowed", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^LimitedPeersAllowed$")),

                                            // These items will not be synced by Octagon
                                            TPPBPolicyKeyViewMapping(view: "NotSynced", matchingRule:
                                                                        TPDictionaryMatchingRule.orMatch([
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^ContinuityUnlock$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^HomeKit$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^AppleTV$"),
                                                                        ])),

                                            TPPBPolicyKeyViewMapping(view: "MFi", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^MFi$")),

                                            TPPBPolicyKeyViewMapping(view: "Applications", matchingRule:
                                                                        TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^[0-9A-Z]{10}\\.")),

                                            TPPBPolicyKeyViewMapping(view: "SecureObjectSync", matchingRule:
                                                                        TPDictionaryMatchingRule.orMatch([
                                                                            TPDictionaryMatchingRule.andMatch([
                                                                                TPDictionaryMatchingRule.fieldMatch("class", fieldRegex: "^genp$"),
                                                                                TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com\\.apple\\.sbd$"),
                                                                            ]),
                                                                            TPDictionaryMatchingRule.andMatch([
                                                                                TPDictionaryMatchingRule.fieldMatch("class", fieldRegex: "^keys$"),
                                                                                TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com\\.apple\\.security\\.sos$"),
                                                                            ]),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^BackupBagV0$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^iCloudIdentity$"),
                                                                        ])),

                                            TPPBPolicyKeyViewMapping(view: "WiFi", matchingRule:
                                                                        TPDictionaryMatchingRule.orMatch([
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^WiFi$"),
                                                                            TPDictionaryMatchingRule.andMatch([
                                                                                TPDictionaryMatchingRule.fieldMatch("class", fieldRegex: "^genp$"),
                                                                                TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^apple$"),
                                                                                TPDictionaryMatchingRule.fieldMatch("svce", fieldRegex: "^AirPort$"),
                                                                            ]),
                                                                        ])),

                                            TPPBPolicyKeyViewMapping(view: "ProtectedCloudStorage", matchingRule:
                                                                        TPDictionaryMatchingRule.orMatch([
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-Backup$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-CloudKit$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-Escrow$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-FDE$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-Feldspar$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-MailDrop$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-Maildrop$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-MasterKey$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-Notes$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-Photos$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-Sharing$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-iCloudBackup$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-iCloudDrive$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-iMessage$"),
                                                                        ])),

                                            TPPBPolicyKeyViewMapping(view: "CreditCards", matchingRule:
                                                                        TPDictionaryMatchingRule.orMatch([
                                                                            TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com\\.apple\\.safari\\.credit-cards$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^CreditCards$"),
                                                                        ])),

                                            TPPBPolicyKeyViewMapping(view: "Passwords", matchingRule:
                                                                        TPDictionaryMatchingRule.orMatch([
                                                                            TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com\\.apple\\.cfnetwork$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com\\.apple\\.password-manager$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com\\.apple\\.WebKit\\.WebAuthn$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com\\.apple\\.webkit\\.webauthn$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^Passwords$"),
                                                                        ])),

                                            TPPBPolicyKeyViewMapping(view: "DevicePairing", matchingRule:
                                                                        TPDictionaryMatchingRule.orMatch([
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^AccessoryPairing$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^NanoRegistry$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^WatchMigration$"),
                                                                        ])),

                                            TPPBPolicyKeyViewMapping(view: "Backstop", matchingRule:
                                                                        TPDictionaryMatchingRule.trueMatch()),
                                          ],
                                          userControllableViewList: [
                                            "Applications",
                                            "Backstop",
                                            "CreditCards",
                                            "Passwords",
                                            "WiFi",
                                          ],
                                          piggybackViews: [
                                            "Passwords",
                                          ],
                                          priorityViews: [
                                            "ProtectedCloudStorage",
                                            "SecureObjectSync",
                                          ],
                                          inheritedExcludedViews: [
                                            "Passwords",
                                          ],
                                          hashAlgo: .SHA256)}),

    RawPolicy(
        version: TPPolicyVersion(version: 13, hash: "SHA256:lZrYULdc8y/68PbqIz3wBGs82z4R+LYUITiTs87SMyg="),
        policyData: { "CA0SDQoHQXBwbGVUVhICdHYSFwoOQXVkaW9BY2Nlc3NvcnkSBWF1ZGlvEgsKA01hYxIEZnVsbBIOCgVXYXRjaBIFd2F0Y2gSEAoFV2luUEMSB3dpbmRvd3MSDAoEaU1hYxIEZnVsbBIMCgRpUGFkEgRmdWxsEg4KBmlQaG9uZRIEZnVsbBIMCgRpUG9kEgRmdWxsGhcKCEFwcGxlUGF5EgRmdWxsEgV3YXRjaBobCgxBcHBsaWNhdGlvbnMSBGZ1bGwSBXdhdGNoGhkKCkF1dG9VbmxvY2sSBGZ1bGwSBXdhdGNoGhcKCEJhY2tzdG9wEgRmdWxsEgV3YXRjaBoaCgtDcmVkaXRDYXJkcxIEZnVsbBI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iGgIEdndodAoSXlBDUy1pQ2xvdWRCYWNrdXAkEh0ABCIZAgR2d2h0ChFeUENTLWlDbG91ZERyaXZlJBIaAAQiFgIEdndodAoOXlBDUy1pTWVzc2FnZSQSFVByb3RlY3RlZENsb3VkU3RvcmFnZTJcCk0AAhIuAAQiKgIEYWdycAoiXmNvbVwuYXBwbGVcLnNhZmFyaVwuY3JlZGl0LWNhcmRzJBIZAAQiFQIEdndodAoNXkNyZWRpdENhcmRzJBILQ3JlZGl0Q2FyZHMy0gEKxAEAAhIjAAQiHwIEYWdycAoXXmNvbVwuYXBwbGVcLmNmbmV0d29yayQSKgAEIiYCBGFncnAKHl5jb21cLmFwcGxlXC5wYXNzd29yZC1tYW5hZ2VyJBIqAAQiJgIEYWdycAoeXmNvbVwuYXBwbGVcLldlYktpdFwuV2ViQXV0aG4kEioABCImAgRhZ3JwCh5eY29tXC5hcHBsZVwud2Via2l0XC53ZWJhdXRobiQSFwAEIhMCBHZ3aHQKC15QYXNzd29yZHMkEglQYXNzd29yZHMybQpcAAISHgAEIhoCBHZ3aHQKEl5BY2Nlc3NvcnlQYWlyaW5nJBIaAAQiFgIEdndodAoOXk5hbm9SZWdpc3RyeSQSHAAEIhgCBHZ3aHQKEF5XYXRjaE1pZ3JhdGlvbiQSDURldmljZVBhaXJpbmcyDgoCAAYSCEJhY2tzdG9wOgxBcHBsaWNhdGlvbnM6CEJhY2tzdG9wOgtDcmVkaXRDYXJkczoJUGFzc3dvcmRzOgRXaUZpQglQYXNzd29yZHNKFVByb3RlY3RlZENsb3VkU3RvcmFnZUoQU2VjdXJlT2JqZWN0U3luY1IJUGFzc3dvcmRz" },
        plaintextPolicy: {TPPolicyDocument(version: 13,
                                          modelToCategory: [
                                            TPPBPolicyModelToCategory(prefix: "AppleTV", category: "tv"),
                                            TPPBPolicyModelToCategory(prefix: "AudioAccessory", category: "audio"),
                                            TPPBPolicyModelToCategory(prefix: "Mac", category: "full"),
                                            TPPBPolicyModelToCategory(prefix: "Watch", category: "watch"),
                                            TPPBPolicyModelToCategory(prefix: "WinPC", category: "windows"),
                                            TPPBPolicyModelToCategory(prefix: "iMac", category: "full"),
                                            TPPBPolicyModelToCategory(prefix: "iPad", category: "full"),
                                            TPPBPolicyModelToCategory(prefix: "iPhone", category: "full"),
                                            TPPBPolicyModelToCategory(prefix: "iPod", category: "full"),
                                          ],
                                          categoriesByView: [
                                            TPPBPolicyCategoriesByView(view: "ApplePay", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "Applications", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "AutoUnlock", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "Backstop", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "CreditCards", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "DevicePairing", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "Engram", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "Health", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "Home", categories: ["full", "watch", "tv", "audio"]),
                                            TPPBPolicyCategoriesByView(view: "LimitedPeersAllowed", categories: ["windows", "full", "watch", "tv", "audio"]),
                                            TPPBPolicyCategoriesByView(view: "Mail", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "MFi", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "Manatee", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "Passwords", categories: ["full", "watch", "windows"]),
                                            TPPBPolicyCategoriesByView(view: "ProtectedCloudStorage", categories: [ "windows", "full", "watch", "tv", "audio"]),
                                            TPPBPolicyCategoriesByView(view: "SecureObjectSync", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "WiFi", categories: ["full", "watch", "tv", "audio"]),
                                          ],
                                          introducersByCategory: [
                                            TPPBPolicyIntroducersByCategory(category: "audio", introducers: ["full", "watch", "audio"]),
                                            TPPBPolicyIntroducersByCategory(category: "full", introducers: ["full", "watch"]),
                                            TPPBPolicyIntroducersByCategory(category: "tv", introducers: ["full", "watch", "tv"]),
                                            TPPBPolicyIntroducersByCategory(category: "watch", introducers: ["full", "watch"]),
                                            TPPBPolicyIntroducersByCategory(category: "windows", introducers: ["full", "watch"]),
                                          ],
                                          redactions: [],
                                          keyViewMapping: [
                                            TPPBPolicyKeyViewMapping(view: "ApplePay", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^ApplePay$")),
                                            TPPBPolicyKeyViewMapping(view: "AutoUnlock", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^AutoUnlock$")),
                                            TPPBPolicyKeyViewMapping(view: "Engram", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^Engram$")),
                                            TPPBPolicyKeyViewMapping(view: "Health", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^Health$")),
                                            TPPBPolicyKeyViewMapping(view: "Home", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^Home$")),
                                            TPPBPolicyKeyViewMapping(view: "Manatee", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^Manatee$")),
                                            TPPBPolicyKeyViewMapping(view: "LimitedPeersAllowed", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^LimitedPeersAllowed$")),

                                            // These items will not be synced by Octagon
                                            TPPBPolicyKeyViewMapping(view: "NotSynced", matchingRule:
                                                                        TPDictionaryMatchingRule.orMatch([
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^ContinuityUnlock$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^HomeKit$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^AppleTV$"),
                                                                        ])),

                                            TPPBPolicyKeyViewMapping(view: "MFi", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^MFi$")),
                                            TPPBPolicyKeyViewMapping(view: "Mail", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^Mail$")),

                                            TPPBPolicyKeyViewMapping(view: "Applications", matchingRule:
                                                                        TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^[0-9A-Z]{10}\\.")),

                                            TPPBPolicyKeyViewMapping(view: "SecureObjectSync", matchingRule:
                                                                        TPDictionaryMatchingRule.orMatch([
                                                                            TPDictionaryMatchingRule.andMatch([
                                                                                TPDictionaryMatchingRule.fieldMatch("class", fieldRegex: "^genp$"),
                                                                                TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com\\.apple\\.sbd$"),
                                                                            ]),
                                                                            TPDictionaryMatchingRule.andMatch([
                                                                                TPDictionaryMatchingRule.fieldMatch("class", fieldRegex: "^keys$"),
                                                                                TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com\\.apple\\.security\\.sos$"),
                                                                            ]),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^BackupBagV0$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^iCloudIdentity$"),
                                                                        ])),

                                            TPPBPolicyKeyViewMapping(view: "WiFi", matchingRule:
                                                                        TPDictionaryMatchingRule.orMatch([
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^WiFi$"),
                                                                            TPDictionaryMatchingRule.andMatch([
                                                                                TPDictionaryMatchingRule.fieldMatch("class", fieldRegex: "^genp$"),
                                                                                TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^apple$"),
                                                                                TPDictionaryMatchingRule.fieldMatch("svce", fieldRegex: "^AirPort$"),
                                                                            ]),
                                                                        ])),

                                            TPPBPolicyKeyViewMapping(view: "ProtectedCloudStorage", matchingRule:
                                                                        TPDictionaryMatchingRule.orMatch([
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-Backup$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-CloudKit$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-Escrow$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-FDE$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-Feldspar$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-MailDrop$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-Maildrop$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-MasterKey$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-Notes$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-Photos$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-Sharing$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-iCloudBackup$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-iCloudDrive$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-iMessage$"),
                                                                        ])),

                                            TPPBPolicyKeyViewMapping(view: "CreditCards", matchingRule:
                                                                        TPDictionaryMatchingRule.orMatch([
                                                                            TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com\\.apple\\.safari\\.credit-cards$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^CreditCards$"),
                                                                        ])),

                                            TPPBPolicyKeyViewMapping(view: "Passwords", matchingRule:
                                                                        TPDictionaryMatchingRule.orMatch([
                                                                            TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com\\.apple\\.cfnetwork$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com\\.apple\\.password-manager$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com\\.apple\\.WebKit\\.WebAuthn$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com\\.apple\\.webkit\\.webauthn$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^Passwords$"),
                                                                        ])),

                                            TPPBPolicyKeyViewMapping(view: "DevicePairing", matchingRule:
                                                                        TPDictionaryMatchingRule.orMatch([
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^AccessoryPairing$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^NanoRegistry$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^WatchMigration$"),
                                                                        ])),

                                            TPPBPolicyKeyViewMapping(view: "Backstop", matchingRule:
                                                                        TPDictionaryMatchingRule.trueMatch()),
                                          ],
                                          userControllableViewList: [
                                            "Applications",
                                            "Backstop",
                                            "CreditCards",
                                            "Passwords",
                                            "WiFi",
                                          ],
                                          piggybackViews: [
                                            "Passwords",
                                          ],
                                          priorityViews: [
                                            "ProtectedCloudStorage",
                                            "SecureObjectSync",
                                          ],
                                          inheritedExcludedViews: [
                                            "Passwords",
                                          ],
                                          hashAlgo: .SHA256)}),

    RawPolicy(
        version: TPPolicyVersion(version: 15, hash: "SHA256:QXtusuXkmY7T1Onw1Q77p91bgG76zzSbqBQIeVnIA1o="),
        policyData: { "CA8SDQoHQXBwbGVUVhICdHYSFwoOQXVkaW9BY2Nlc3NvcnkSBWF1ZGlvEgsKA01hYxIEZnVsbBIOCgVXYXRjaBIFd2F0Y2gSEAoFV2luUEMSB3dpbmRvd3MSDAoEaU1hYxIEZnVsbBIMCgRpUGFkEgRmdWxsEg4KBmlQaG9uZRIEZnVsbBIMCgRpUG9kEgRmdWxsGhcKCEFwcGxlUGF5EgRmdWxsEgV3YXRjaBobCgxBcHBsaWNhdGlvbn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c3dvcmRzMm0KXAACEh4ABCIaAgR2d2h0ChJeQWNjZXNzb3J5UGFpcmluZyQSGgAEIhYCBHZ3aHQKDl5OYW5vUmVnaXN0cnkkEhwABCIYAgR2d2h0ChBeV2F0Y2hNaWdyYXRpb24kEg1EZXZpY2VQYWlyaW5nMg4KAgAGEghCYWNrc3RvcDoMQXBwbGljYXRpb25zOghCYWNrc3RvcDoLQ3JlZGl0Q2FyZHM6CVBhc3N3b3JkczoEV2lGaUIJUGFzc3dvcmRzShVQcm90ZWN0ZWRDbG91ZFN0b3JhZ2VKEFNlY3VyZU9iamVjdFN5bmNSCVBhc3N3b3Jkcw==" },
        plaintextPolicy: {TPPolicyDocument(version: 15,
                                          modelToCategory: [
                                            TPPBPolicyModelToCategory(prefix: "AppleTV", category: "tv"),
                                            TPPBPolicyModelToCategory(prefix: "AudioAccessory", category: "audio"),
                                            TPPBPolicyModelToCategory(prefix: "Mac", category: "full"),
                                            TPPBPolicyModelToCategory(prefix: "Watch", category: "watch"),
                                            TPPBPolicyModelToCategory(prefix: "WinPC", category: "windows"),
                                            TPPBPolicyModelToCategory(prefix: "iMac", category: "full"),
                                            TPPBPolicyModelToCategory(prefix: "iPad", category: "full"),
                                            TPPBPolicyModelToCategory(prefix: "iPhone", category: "full"),
                                            TPPBPolicyModelToCategory(prefix: "iPod", category: "full"),
                                          ],
                                          categoriesByView: [
                                            TPPBPolicyCategoriesByView(view: "ApplePay", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "Applications", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "AutoUnlock", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "Backstop", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "CreditCards", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "DevicePairing", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "Engram", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "Health", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "Home", categories: ["full", "watch", "tv", "audio"]),
                                            TPPBPolicyCategoriesByView(view: "LimitedPeersAllowed", categories: ["windows", "full", "watch", "tv", "audio"]),
                                            TPPBPolicyCategoriesByView(view: "Mail", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "MFi", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "Manatee", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "Passwords", categories: ["full", "watch", "windows"]),
                                            TPPBPolicyCategoriesByView(view: "ProtectedCloudStorage", categories: [ "windows", "full", "watch", "tv", "audio"]),
                                            TPPBPolicyCategoriesByView(view: "SecureObjectSync", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "WiFi", categories: ["full", "watch", "tv", "audio"]),
                                          ],
                                          introducersByCategory: [
                                            TPPBPolicyIntroducersByCategory(category: "audio", introducers: ["full", "watch", "audio"]),
                                            TPPBPolicyIntroducersByCategory(category: "full", introducers: ["full", "watch"]),
                                            TPPBPolicyIntroducersByCategory(category: "tv", introducers: ["full", "watch", "tv"]),
                                            TPPBPolicyIntroducersByCategory(category: "watch", introducers: ["full", "watch"]),
                                            TPPBPolicyIntroducersByCategory(category: "windows", introducers: ["full", "watch"]),
                                          ],
                                          redactions: [],
                                          keyViewMapping: [
                                            TPPBPolicyKeyViewMapping(view: "ApplePay", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^ApplePay$")),
                                            TPPBPolicyKeyViewMapping(view: "AutoUnlock", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^AutoUnlock$")),
                                            TPPBPolicyKeyViewMapping(view: "Engram", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^Engram$")),
                                            TPPBPolicyKeyViewMapping(view: "Health", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^Health$")),
                                            TPPBPolicyKeyViewMapping(view: "Home", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^Home$")),
                                            TPPBPolicyKeyViewMapping(view: "Manatee", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^Manatee$")),
                                            TPPBPolicyKeyViewMapping(view: "LimitedPeersAllowed", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^LimitedPeersAllowed$")),

                                            // These items will not be synced by Octagon
                                            TPPBPolicyKeyViewMapping(view: "NotSynced", matchingRule:
                                                                        TPDictionaryMatchingRule.orMatch([
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^ContinuityUnlock$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^HomeKit$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^AppleTV$"),
                                                                        ])),

                                            TPPBPolicyKeyViewMapping(view: "MFi", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^MFi$")),
                                            TPPBPolicyKeyViewMapping(view: "Mail", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^Mail$")),

                                            TPPBPolicyKeyViewMapping(view: "Applications", matchingRule:
                                                                        TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^[0-9A-Z]{10}\\.")),

                                            TPPBPolicyKeyViewMapping(view: "SecureObjectSync", matchingRule:
                                                                        TPDictionaryMatchingRule.orMatch([
                                                                            TPDictionaryMatchingRule.andMatch([
                                                                                TPDictionaryMatchingRule.fieldMatch("class", fieldRegex: "^genp$"),
                                                                                TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com\\.apple\\.sbd$"),
                                                                            ]),
                                                                            TPDictionaryMatchingRule.andMatch([
                                                                                TPDictionaryMatchingRule.fieldMatch("class", fieldRegex: "^keys$"),
                                                                                TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com\\.apple\\.security\\.sos$"),
                                                                            ]),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^BackupBagV0$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^iCloudIdentity$"),
                                                                        ])),

                                            TPPBPolicyKeyViewMapping(view: "WiFi", matchingRule:
                                                                        TPDictionaryMatchingRule.orMatch([
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^WiFi$"),
                                                                            TPDictionaryMatchingRule.andMatch([
                                                                                TPDictionaryMatchingRule.fieldMatch("class", fieldRegex: "^genp$"),
                                                                                TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^apple$"),
                                                                                TPDictionaryMatchingRule.fieldMatch("svce", fieldRegex: "^AirPort$"),
                                                                            ]),
                                                                        ])),

                                            TPPBPolicyKeyViewMapping(view: "ProtectedCloudStorage", matchingRule:
                                                                        TPDictionaryMatchingRule.orMatch([
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-Backup$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-CloudKit$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-Escrow$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-FDE$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-Feldspar$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-MailDrop$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-Maildrop$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-MasterKey$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-Notes$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-Photos$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-Sharing$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-iCloudBackup$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-iCloudDrive$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-iMessage$"),
                                                                        ])),

                                            TPPBPolicyKeyViewMapping(view: "CreditCards", matchingRule:
                                                                        TPDictionaryMatchingRule.orMatch([
                                                                            TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com\\.apple\\.safari\\.credit-cards$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^CreditCards$"),
                                                                        ])),

                                            TPPBPolicyKeyViewMapping(view: "Passwords", matchingRule:
                                                                        TPDictionaryMatchingRule.orMatch([
                                                                            TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com\\.apple\\.cfnetwork$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com\\.apple\\.cfnetwork-recently-deleted$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com\\.apple\\.password-manager$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com\\.apple\\.password-manager-recently-deleted$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com\\.apple\\.WebKit\\.WebAuthn$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com\\.apple\\.webkit\\.webauthn$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com\\.apple\\.webkit\\.webauthn-recently-deleted$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com\\.apple\\.password-manager\\.personal$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com\\.apple\\.password-manager\\.personal-recently-deleted$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^Passwords$"),
                                                                        ])),

                                            TPPBPolicyKeyViewMapping(view: "DevicePairing", matchingRule:
                                                                        TPDictionaryMatchingRule.orMatch([
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^AccessoryPairing$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^NanoRegistry$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^WatchMigration$"),
                                                                        ])),

                                            TPPBPolicyKeyViewMapping(view: "Backstop", matchingRule:
                                                                        TPDictionaryMatchingRule.trueMatch()),
                                          ],
                                          userControllableViewList: [
                                            "Applications",
                                            "Backstop",
                                            "CreditCards",
                                            "Passwords",
                                            "WiFi",
                                          ],
                                          piggybackViews: [
                                            "Passwords",
                                          ],
                                          priorityViews: [
                                            "ProtectedCloudStorage",
                                            "SecureObjectSync",
                                          ],
                                          inheritedExcludedViews: [
                                            "Passwords",
                                          ],
                                          hashAlgo: .SHA256)}),

    // Policy 16 does not have the new content in policy 15.
    RawPolicy(
        version: TPPolicyVersion(version: 16, hash: "SHA256:/4gt8WFEXCVLYI+C+8/2MiMz6Srv0vpcvlkJ4gkepHQ="),
        policyData: { "CBASDQoHQXBwbGVUVhICdHYSFwoOQXVkaW9BY2Nlc3NvcnkSBWF1ZGlvEgsKA01hYxIEZnVsbBIOCgVXYXRjaBIFd2F0Y2gSEAoFV2luUEMSB3dpbmRvd3MSDAoEaU1hYxIEZnVsbBIMCgRpUGFkEgRmdWxsEg4KBmlQaG9uZRIEZnVsbBIMCgRpUG9kEgRmdWxsGhcKCEFwcGxlUGF5EgRmdWxsEgV3YXRjaBobCgxBcHBsaWNhdGlvbnMSBGZ1bGwSBXdhdGNoGhkKCkF1dG9VbmxvY2sSBGZ1bGwSBXdhdGNoGhcKCEJhY2tzdG9wEgRmdWxsEgV3YXRjaBoaCgtDcmVkaXRDYXJkcxIEZnVsbBIFd2F0Y2gaFwoIQ29udGFjdHMSBGZ1bGwSBXdhdGNoGhw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QKDV5QQ1MtU2hhcmluZyQSHgAEIhoCBHZ3aHQKEl5QQ1MtaUNsb3VkQmFja3VwJBIdAAQiGQIEdndodAoRXlBDUy1pQ2xvdWREcml2ZSQSGgAEIhYCBHZ3aHQKDl5QQ1MtaU1lc3NhZ2UkEhVQcm90ZWN0ZWRDbG91ZFN0b3JhZ2UyXApNAAISLgAEIioCBGFncnAKIl5jb21cLmFwcGxlXC5zYWZhcmlcLmNyZWRpdC1jYXJkcyQSGQAEIhUCBHZ3aHQKDV5DcmVkaXRDYXJkcyQSC0NyZWRpdENhcmRzMtIBCsQBAAISIwAEIh8CBGFncnAKF15jb21cLmFwcGxlXC5jZm5ldHdvcmskEioABCImAgRhZ3JwCh5eY29tXC5hcHBsZVwucGFzc3dvcmQtbWFuYWdlciQSKgAEIiYCBGFncnAKHl5jb21cLmFwcGxlXC5XZWJLaXRcLldlYkF1dGhuJBIqAAQiJgIEYWdycAoeXmNvbVwuYXBwbGVcLndlYmtpdFwud2ViYXV0aG4kEhcABCITAgR2d2h0CgteUGFzc3dvcmRzJBIJUGFzc3dvcmRzMm0KXAACEh4ABCIaAgR2d2h0ChJeQWNjZXNzb3J5UGFpcmluZyQSGgAEIhYCBHZ3aHQKDl5OYW5vUmVnaXN0cnkkEhwABCIYAgR2d2h0ChBeV2F0Y2hNaWdyYXRpb24kEg1EZXZpY2VQYWlyaW5nMg4KAgAGEghCYWNrc3RvcDoMQXBwbGljYXRpb25zOghCYWNrc3RvcDoLQ3JlZGl0Q2FyZHM6CVBhc3N3b3JkczoEV2lGaUIJUGFzc3dvcmRzShVQcm90ZWN0ZWRDbG91ZFN0b3JhZ2VKEFNlY3VyZU9iamVjdFN5bmNSCVBhc3N3b3Jkcw==" },
        plaintextPolicy: {TPPolicyDocument(version: 16,
                                          modelToCategory: [
                                            TPPBPolicyModelToCategory(prefix: "AppleTV", category: "tv"),
                                            TPPBPolicyModelToCategory(prefix: "AudioAccessory", category: "audio"),
                                            TPPBPolicyModelToCategory(prefix: "Mac", category: "full"),
                                            TPPBPolicyModelToCategory(prefix: "Watch", category: "watch"),
                                            TPPBPolicyModelToCategory(prefix: "WinPC", category: "windows"),
                                            TPPBPolicyModelToCategory(prefix: "iMac", category: "full"),
                                            TPPBPolicyModelToCategory(prefix: "iPad", category: "full"),
                                            TPPBPolicyModelToCategory(prefix: "iPhone", category: "full"),
                                            TPPBPolicyModelToCategory(prefix: "iPod", category: "full"),
                                          ],
                                          categoriesByView: [
                                            TPPBPolicyCategoriesByView(view: "ApplePay", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "Applications", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "AutoUnlock", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "Backstop", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "CreditCards", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "Contacts", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "DevicePairing", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "Engram", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "Health", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "Home", categories: ["full", "watch", "tv", "audio"]),
                                            TPPBPolicyCategoriesByView(view: "LimitedPeersAllowed", categories: ["windows", "full", "watch", "tv", "audio"]),
                                            TPPBPolicyCategoriesByView(view: "Mail", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "MFi", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "Manatee", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "Passwords", categories: ["full", "watch", "windows"]),
                                            TPPBPolicyCategoriesByView(view: "ProtectedCloudStorage", categories: [ "windows", "full", "watch", "tv", "audio"]),
                                            TPPBPolicyCategoriesByView(view: "SecureObjectSync", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "WiFi", categories: ["full", "watch", "tv", "audio"]),
                                          ],
                                          introducersByCategory: [
                                            TPPBPolicyIntroducersByCategory(category: "audio", introducers: ["full", "watch", "audio"]),
                                            TPPBPolicyIntroducersByCategory(category: "full", introducers: ["full", "watch"]),
                                            TPPBPolicyIntroducersByCategory(category: "tv", introducers: ["full", "watch", "tv"]),
                                            TPPBPolicyIntroducersByCategory(category: "watch", introducers: ["full", "watch"]),
                                            TPPBPolicyIntroducersByCategory(category: "windows", introducers: ["full", "watch"]),
                                          ],
                                          redactions: [],
                                          keyViewMapping: [
                                            TPPBPolicyKeyViewMapping(view: "ApplePay", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^ApplePay$")),
                                            TPPBPolicyKeyViewMapping(view: "AutoUnlock", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^AutoUnlock$")),
                                            TPPBPolicyKeyViewMapping(view: "Engram", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^Engram$")),
                                            TPPBPolicyKeyViewMapping(view: "Health", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^Health$")),
                                            TPPBPolicyKeyViewMapping(view: "Home", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^Home$")),
                                            TPPBPolicyKeyViewMapping(view: "Manatee", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^Manatee$")),
                                            TPPBPolicyKeyViewMapping(view: "LimitedPeersAllowed", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^LimitedPeersAllowed$")),

                                            // These items will not be synced by Octagon
                                            TPPBPolicyKeyViewMapping(view: "NotSynced", matchingRule:
                                                                        TPDictionaryMatchingRule.orMatch([
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^ContinuityUnlock$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^HomeKit$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^AppleTV$"),
                                                                        ])),

                                            TPPBPolicyKeyViewMapping(view: "MFi", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^MFi$")),
                                            TPPBPolicyKeyViewMapping(view: "Mail", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^Mail$")),
                                            TPPBPolicyKeyViewMapping(view: "Contacts", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^Contacts$")),

                                            TPPBPolicyKeyViewMapping(view: "Applications", matchingRule:
                                                                        TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^[0-9A-Z]{10}\\.")),

                                            TPPBPolicyKeyViewMapping(view: "SecureObjectSync", matchingRule:
                                                                        TPDictionaryMatchingRule.orMatch([
                                                                            TPDictionaryMatchingRule.andMatch([
                                                                                TPDictionaryMatchingRule.fieldMatch("class", fieldRegex: "^genp$"),
                                                                                TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com\\.apple\\.sbd$"),
                                                                            ]),
                                                                            TPDictionaryMatchingRule.andMatch([
                                                                                TPDictionaryMatchingRule.fieldMatch("class", fieldRegex: "^keys$"),
                                                                                TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com\\.apple\\.security\\.sos$"),
                                                                            ]),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^BackupBagV0$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^iCloudIdentity$"),
                                                                        ])),

                                            TPPBPolicyKeyViewMapping(view: "WiFi", matchingRule:
                                                                        TPDictionaryMatchingRule.orMatch([
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^WiFi$"),
                                                                            TPDictionaryMatchingRule.andMatch([
                                                                                TPDictionaryMatchingRule.fieldMatch("class", fieldRegex: "^genp$"),
                                                                                TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^apple$"),
                                                                                TPDictionaryMatchingRule.fieldMatch("svce", fieldRegex: "^AirPort$"),
                                                                            ]),
                                                                        ])),

                                            TPPBPolicyKeyViewMapping(view: "ProtectedCloudStorage", matchingRule:
                                                                        TPDictionaryMatchingRule.orMatch([
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-Backup$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-CloudKit$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-Escrow$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-FDE$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-Feldspar$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-MailDrop$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-Maildrop$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-MasterKey$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-Notes$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-Photos$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-Sharing$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-iCloudBackup$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-iCloudDrive$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-iMessage$"),
                                                                        ])),

                                            TPPBPolicyKeyViewMapping(view: "CreditCards", matchingRule:
                                                                        TPDictionaryMatchingRule.orMatch([
                                                                            TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com\\.apple\\.safari\\.credit-cards$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^CreditCards$"),
                                                                        ])),

                                            TPPBPolicyKeyViewMapping(view: "Passwords", matchingRule:
                                                                        TPDictionaryMatchingRule.orMatch([
                                                                            TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com\\.apple\\.cfnetwork$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com\\.apple\\.password-manager$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com\\.apple\\.WebKit\\.WebAuthn$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com\\.apple\\.webkit\\.webauthn$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^Passwords$"),
                                                                        ])),

                                            TPPBPolicyKeyViewMapping(view: "DevicePairing", matchingRule:
                                                                        TPDictionaryMatchingRule.orMatch([
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^AccessoryPairing$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^NanoRegistry$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^WatchMigration$"),
                                                                        ])),

                                            TPPBPolicyKeyViewMapping(view: "Backstop", matchingRule:
                                                                        TPDictionaryMatchingRule.trueMatch()),
                                          ],
                                          userControllableViewList: [
                                            "Applications",
                                            "Backstop",
                                            "CreditCards",
                                            "Passwords",
                                            "WiFi",
                                          ],
                                          piggybackViews: [
                                            "Passwords",
                                          ],
                                          priorityViews: [
                                            "ProtectedCloudStorage",
                                            "SecureObjectSync",
                                          ],
                                          inheritedExcludedViews: [
                                            "Passwords",
                                          ],
                                          hashAlgo: .SHA256)}),

    // Policy 17 combines policy 15 and 16, and adds the Groups and Photos CKKS views.
    RawPolicy(
        version: TPPolicyVersion(version: 17, hash: "SHA256:bUxscXypxoKd+JQ2sa/pOVhnMcF6uOJN7yW+CLQDIq0="),
        policyData: { "CBESDQoHQXBwbGVUVhICdHYSFwoOQXVkaW9BY2Nlc3NvcnkSBWF1Z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uYXBwbGVcLnBhc3N3b3JkLW1hbmFnZXItcmVjZW50bHktZGVsZXRlZCQSKgAEIiYCBGFncnAKHl5jb21cLmFwcGxlXC5XZWJLaXRcLldlYkF1dGhuJBIqAAQiJgIEYWdycAoeXmNvbVwuYXBwbGVcLndlYmtpdFwud2ViYXV0aG4kEjsABCI3AgRhZ3JwCi9eY29tXC5hcHBsZVwud2Via2l0XC53ZWJhdXRobi1yZWNlbnRseS1kZWxldGVkJBI0AAQiMAIEYWdycAooXmNvbVwuYXBwbGVcLnBhc3N3b3JkLW1hbmFnZXJcLnBlcnNvbmFsJBJFAAQiQQIEYWdycAo5XmNvbVwuYXBwbGVcLnBhc3N3b3JkLW1hbmFnZXJcLnBlcnNvbmFsLXJlY2VudGx5LWRlbGV0ZWQkEhcABCITAgR2d2h0CgteUGFzc3dvcmRzJBIJUGFzc3dvcmRzMm0KXAACEh4ABCIaAgR2d2h0ChJeQWNjZXNzb3J5UGFpcmluZyQSGgAEIhYCBHZ3aHQKDl5OYW5vUmVnaXN0cnkkEhwABCIYAgR2d2h0ChBeV2F0Y2hNaWdyYXRpb24kEg1EZXZpY2VQYWlyaW5nMg4KAgAGEghCYWNrc3RvcDoMQXBwbGljYXRpb25zOghCYWNrc3RvcDoLQ3JlZGl0Q2FyZHM6CVBhc3N3b3JkczoEV2lGaUIJUGFzc3dvcmRzShVQcm90ZWN0ZWRDbG91ZFN0b3JhZ2VKEFNlY3VyZU9iamVjdFN5bmNSCVBhc3N3b3Jkcw==" },
        plaintextPolicy: {TPPolicyDocument(version: 17,
                                          modelToCategory: [
                                            TPPBPolicyModelToCategory(prefix: "AppleTV", category: "tv"),
                                            TPPBPolicyModelToCategory(prefix: "AudioAccessory", category: "audio"),
                                            TPPBPolicyModelToCategory(prefix: "Mac", category: "full"),
                                            TPPBPolicyModelToCategory(prefix: "Watch", category: "watch"),
                                            TPPBPolicyModelToCategory(prefix: "WinPC", category: "windows"),
                                            TPPBPolicyModelToCategory(prefix: "iMac", category: "full"),
                                            TPPBPolicyModelToCategory(prefix: "iPad", category: "full"),
                                            TPPBPolicyModelToCategory(prefix: "iPhone", category: "full"),
                                            TPPBPolicyModelToCategory(prefix: "iPod", category: "full"),
                                          ],
                                          categoriesByView: [
                                            TPPBPolicyCategoriesByView(view: "ApplePay", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "Applications", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "AutoUnlock", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "Backstop", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "CreditCards", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "Contacts", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "DevicePairing", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "Engram", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "Groups", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "Health", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "Home", categories: ["full", "watch", "tv", "audio"]),
                                            TPPBPolicyCategoriesByView(view: "LimitedPeersAllowed", categories: ["windows", "full", "watch", "tv", "audio"]),
                                            TPPBPolicyCategoriesByView(view: "Mail", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "MFi", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "Manatee", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "Passwords", categories: ["full", "watch", "windows"]),
                                            TPPBPolicyCategoriesByView(view: "Photos", categories: ["full", "watch", "windows"]),
                                            TPPBPolicyCategoriesByView(view: "ProtectedCloudStorage", categories: [ "windows", "full", "watch", "tv", "audio"]),
                                            TPPBPolicyCategoriesByView(view: "SecureObjectSync", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "WiFi", categories: ["full", "watch", "tv", "audio"]),
                                          ],
                                          introducersByCategory: [
                                            TPPBPolicyIntroducersByCategory(category: "audio", introducers: ["full", "watch", "audio"]),
                                            TPPBPolicyIntroducersByCategory(category: "full", introducers: ["full", "watch"]),
                                            TPPBPolicyIntroducersByCategory(category: "tv", introducers: ["full", "watch", "tv"]),
                                            TPPBPolicyIntroducersByCategory(category: "watch", introducers: ["full", "watch"]),
                                            TPPBPolicyIntroducersByCategory(category: "windows", introducers: ["full", "watch"]),
                                          ],
                                          redactions: [],
                                          keyViewMapping: [
                                            TPPBPolicyKeyViewMapping(view: "ApplePay", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^ApplePay$")),
                                            TPPBPolicyKeyViewMapping(view: "AutoUnlock", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^AutoUnlock$")),
                                            TPPBPolicyKeyViewMapping(view: "Engram", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^Engram$")),
                                            TPPBPolicyKeyViewMapping(view: "Health", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^Health$")),
                                            TPPBPolicyKeyViewMapping(view: "Home", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^Home$")),
                                            TPPBPolicyKeyViewMapping(view: "Manatee", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^Manatee$")),
                                            TPPBPolicyKeyViewMapping(view: "LimitedPeersAllowed", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^LimitedPeersAllowed$")),

                                            // These items will not be synced by Octagon
                                            TPPBPolicyKeyViewMapping(view: "NotSynced", matchingRule:
                                                                        TPDictionaryMatchingRule.orMatch([
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^ContinuityUnlock$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^HomeKit$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^AppleTV$"),
                                                                        ])),

                                            TPPBPolicyKeyViewMapping(view: "MFi", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^MFi$")),
                                            TPPBPolicyKeyViewMapping(view: "Mail", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^Mail$")),
                                            TPPBPolicyKeyViewMapping(view: "Contacts", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^Contacts$")),
                                            TPPBPolicyKeyViewMapping(view: "Photos", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^Photos$")),
                                            TPPBPolicyKeyViewMapping(view: "Groups", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^Groups$")),

                                            TPPBPolicyKeyViewMapping(view: "Applications", matchingRule:
                                                                        TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^[0-9A-Z]{10}\\.")),

                                            TPPBPolicyKeyViewMapping(view: "SecureObjectSync", matchingRule:
                                                                        TPDictionaryMatchingRule.orMatch([
                                                                            TPDictionaryMatchingRule.andMatch([
                                                                                TPDictionaryMatchingRule.fieldMatch("class", fieldRegex: "^genp$"),
                                                                                TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com\\.apple\\.sbd$"),
                                                                            ]),
                                                                            TPDictionaryMatchingRule.andMatch([
                                                                                TPDictionaryMatchingRule.fieldMatch("class", fieldRegex: "^keys$"),
                                                                                TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com\\.apple\\.security\\.sos$"),
                                                                            ]),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^BackupBagV0$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^iCloudIdentity$"),
                                                                        ])),

                                            TPPBPolicyKeyViewMapping(view: "WiFi", matchingRule:
                                                                        TPDictionaryMatchingRule.orMatch([
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^WiFi$"),
                                                                            TPDictionaryMatchingRule.andMatch([
                                                                                TPDictionaryMatchingRule.fieldMatch("class", fieldRegex: "^genp$"),
                                                                                TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^apple$"),
                                                                                TPDictionaryMatchingRule.fieldMatch("svce", fieldRegex: "^AirPort$"),
                                                                            ]),
                                                                        ])),

                                            TPPBPolicyKeyViewMapping(view: "ProtectedCloudStorage", matchingRule:
                                                                        TPDictionaryMatchingRule.orMatch([
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-Backup$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-CloudKit$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-Escrow$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-FDE$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-Feldspar$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-MailDrop$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-Maildrop$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-MasterKey$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-Notes$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-Photos$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-Sharing$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-iCloudBackup$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-iCloudDrive$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-iMessage$"),
                                                                        ])),

                                            TPPBPolicyKeyViewMapping(view: "CreditCards", matchingRule:
                                                                        TPDictionaryMatchingRule.orMatch([
                                                                            TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com\\.apple\\.safari\\.credit-cards$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^CreditCards$"),
                                                                        ])),

                                            TPPBPolicyKeyViewMapping(view: "Passwords", matchingRule:
                                                                        TPDictionaryMatchingRule.orMatch([
                                                                            TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com\\.apple\\.cfnetwork$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com\\.apple\\.cfnetwork-recently-deleted$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com\\.apple\\.password-manager$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com\\.apple\\.password-manager-recently-deleted$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com\\.apple\\.WebKit\\.WebAuthn$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com\\.apple\\.webkit\\.webauthn$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com\\.apple\\.webkit\\.webauthn-recently-deleted$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com\\.apple\\.password-manager\\.personal$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com\\.apple\\.password-manager\\.personal-recently-deleted$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^Passwords$"),
                                                                        ])),

                                            TPPBPolicyKeyViewMapping(view: "DevicePairing", matchingRule:
                                                                        TPDictionaryMatchingRule.orMatch([
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^AccessoryPairing$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^NanoRegistry$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^WatchMigration$"),
                                                                        ])),

                                            TPPBPolicyKeyViewMapping(view: "Backstop", matchingRule:
                                                                        TPDictionaryMatchingRule.trueMatch()),
                                          ],
                                          userControllableViewList: [
                                            "Applications",
                                            "Backstop",
                                            "CreditCards",
                                            "Passwords",
                                            "WiFi",
                                          ],
                                          piggybackViews: [
                                            "Passwords",
                                          ],
                                          priorityViews: [
                                            "ProtectedCloudStorage",
                                            "SecureObjectSync",
                                          ],
                                          inheritedExcludedViews: [
                                            "Passwords",
                                          ],
                                          hashAlgo: .SHA256)}),

    RawPolicy(
        version: TPPolicyVersion(version: 18, hash: "SHA256:15d6UrHkEIdJcS5VSID0UzMAaCN5eyfmyAM1GC2cG5E="),
        policyData: { "CBISDQoHQXBwbGVUVhICdHYSFwoOQXVkaW9BY2Nlc3NvcnkSBWF1ZGlvEgsKA01hYxIEZnVsbBIOCgVXYXRjaBIFd2F0Y2gSEAoFV2luUEMSB3dpbmRvd3MSDAoEaU1hYxIEZnVsbBIMCgRpUGFkEgRmdWxsEg4KBmlQaG9uZRIEZnVsbBIMCgRpUG9kEgRmdWxsGhcKCEFwcGxlUGF5EgRmdWxsEgV3YXRjaBobCgxBcHBsaWNhdGlvbnMSBGZ1bGwSBXdhdGNoGhkKCkF1dG9VbmxvY2sSBGZ1bGwSBXdhdGNoGhcKCEJhY2tzdG9wEgRmdWxsEgV3YXRjaBoaCgtDcmVkaXRDYXJkcxIEZnVsbBIFd2F0Y2gaFwoIQ29udGFjdHMSBGZ1bGwSBXdhdGNoGhwKDURldmljZVBhaXJpbmcSBGZ1bGwSBXdhdGNoGhUKBkVuZ3JhbRIEZnVsbBIFd2F0Y2gaFQoGR3JvdXBzEgRmdWxsEgV3YXRjaBoVCgZIZWFsdGgSBGZ1bGwSBXdhdGNoGh4KBEhvbWUSBGZ1bGwSBXdhdGNoEgJ0dhIFYXVkaW8aNgoTTGltaXRlZFBlZXJzQWxsb3dlZBIHd2luZG93cxIEZnVsbBIFd2F0Y2gSAnR2EgVhdWRpbxoTCgRNYWlsE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3dvcmRzJBIJUGFzc3dvcmRzMm0KXAACEh4ABCIaAgR2d2h0ChJeQWNjZXNzb3J5UGFpcmluZyQSGgAEIhYCBHZ3aHQKDl5OYW5vUmVnaXN0cnkkEhwABCIYAgR2d2h0ChBeV2F0Y2hNaWdyYXRpb24kEg1EZXZpY2VQYWlyaW5nMg4KAgAGEghCYWNrc3RvcDoMQXBwbGljYXRpb25zOghCYWNrc3RvcDoLQ3JlZGl0Q2FyZHM6CVBhc3N3b3JkczoEV2lGaUIJUGFzc3dvcmRzShVQcm90ZWN0ZWRDbG91ZFN0b3JhZ2VKEFNlY3VyZU9iamVjdFN5bmNSCVBhc3N3b3Jkcw==" },
        plaintextPolicy: {TPPolicyDocument(version: 18,
                                          modelToCategory: [
                                            TPPBPolicyModelToCategory(prefix: "AppleTV", category: "tv"),
                                            TPPBPolicyModelToCategory(prefix: "AudioAccessory", category: "audio"),
                                            TPPBPolicyModelToCategory(prefix: "Mac", category: "full"),
                                            TPPBPolicyModelToCategory(prefix: "Watch", category: "watch"),
                                            TPPBPolicyModelToCategory(prefix: "WinPC", category: "windows"),
                                            TPPBPolicyModelToCategory(prefix: "iMac", category: "full"),
                                            TPPBPolicyModelToCategory(prefix: "iPad", category: "full"),
                                            TPPBPolicyModelToCategory(prefix: "iPhone", category: "full"),
                                            TPPBPolicyModelToCategory(prefix: "iPod", category: "full"),
                                          ],
                                          categoriesByView: [
                                            TPPBPolicyCategoriesByView(view: "ApplePay", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "Applications", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "AutoUnlock", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "Backstop", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "CreditCards", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "Contacts", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "DevicePairing", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "Engram", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "Groups", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "Health", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "Home", categories: ["full", "watch", "tv", "audio"]),
                                            TPPBPolicyCategoriesByView(view: "LimitedPeersAllowed", categories: ["windows", "full", "watch", "tv", "audio"]),
                                            TPPBPolicyCategoriesByView(view: "Mail", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "MFi", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "Manatee", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "Passwords", categories: ["full", "watch", "windows"]),
                                            TPPBPolicyCategoriesByView(view: "Photos", categories: ["full", "watch", "windows"]),
                                            TPPBPolicyCategoriesByView(view: "ProtectedCloudStorage", categories: [ "windows", "full", "watch", "tv", "audio"]),
                                            TPPBPolicyCategoriesByView(view: "SecureObjectSync", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "WiFi", categories: ["full", "watch", "tv", "audio"]),
                                          ],
                                          introducersByCategory: [
                                            TPPBPolicyIntroducersByCategory(category: "audio", introducers: ["full", "watch", "audio"]),
                                            TPPBPolicyIntroducersByCategory(category: "full", introducers: ["full", "watch"]),
                                            TPPBPolicyIntroducersByCategory(category: "tv", introducers: ["full", "watch", "tv"]),
                                            TPPBPolicyIntroducersByCategory(category: "watch", introducers: ["full", "watch"]),
                                            TPPBPolicyIntroducersByCategory(category: "windows", introducers: ["full", "watch"]),
                                          ],
                                          redactions: [],
                                          keyViewMapping: [
                                            TPPBPolicyKeyViewMapping(view: "ApplePay", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^ApplePay$")),
                                            TPPBPolicyKeyViewMapping(view: "AutoUnlock", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^AutoUnlock$")),
                                            TPPBPolicyKeyViewMapping(view: "Engram", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^Engram$")),
                                            TPPBPolicyKeyViewMapping(view: "Health", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^Health$")),
                                            TPPBPolicyKeyViewMapping(view: "Home", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^Home$")),
                                            TPPBPolicyKeyViewMapping(view: "Manatee", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^Manatee$")),
                                            TPPBPolicyKeyViewMapping(view: "LimitedPeersAllowed", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^LimitedPeersAllowed$")),

                                            // These items will not be synced by Octagon
                                            TPPBPolicyKeyViewMapping(view: "NotSynced", matchingRule:
                                                                        TPDictionaryMatchingRule.orMatch([
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^ContinuityUnlock$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^HomeKit$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^AppleTV$"),
                                                                        ])),

                                            TPPBPolicyKeyViewMapping(view: "MFi", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^MFi$")),
                                            TPPBPolicyKeyViewMapping(view: "Mail", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^Mail$")),
                                            TPPBPolicyKeyViewMapping(view: "Contacts", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^Contacts$")),
                                            TPPBPolicyKeyViewMapping(view: "Photos", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^Photos$")),
                                            TPPBPolicyKeyViewMapping(view: "Groups", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^Groups$")),

                                            TPPBPolicyKeyViewMapping(view: "Applications", matchingRule:
                                                                        TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^[0-9A-Z]{10}\\.")),

                                            TPPBPolicyKeyViewMapping(view: "SecureObjectSync", matchingRule:
                                                                        TPDictionaryMatchingRule.orMatch([
                                                                            TPDictionaryMatchingRule.andMatch([
                                                                                TPDictionaryMatchingRule.fieldMatch("class", fieldRegex: "^genp$"),
                                                                                TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com\\.apple\\.sbd$"),
                                                                            ]),
                                                                            TPDictionaryMatchingRule.andMatch([
                                                                                TPDictionaryMatchingRule.fieldMatch("class", fieldRegex: "^keys$"),
                                                                                TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com\\.apple\\.security\\.sos$"),
                                                                            ]),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^BackupBagV0$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^iCloudIdentity$"),
                                                                        ])),

                                            TPPBPolicyKeyViewMapping(view: "WiFi", matchingRule:
                                                                        TPDictionaryMatchingRule.orMatch([
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^WiFi$"),
                                                                            TPDictionaryMatchingRule.andMatch([
                                                                                TPDictionaryMatchingRule.fieldMatch("class", fieldRegex: "^genp$"),
                                                                                TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^apple$"),
                                                                                TPDictionaryMatchingRule.fieldMatch("svce", fieldRegex: "^AirPort$"),
                                                                            ]),
                                                                        ])),

                                            TPPBPolicyKeyViewMapping(view: "ProtectedCloudStorage", matchingRule:
                                                                        TPDictionaryMatchingRule.orMatch([
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-Backup$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-CloudKit$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-Escrow$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-FDE$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-Feldspar$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-MailDrop$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-Maildrop$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-MasterKey$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-Notes$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-Photos$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-Sharing$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-iCloudBackup$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-iCloudDrive$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-iMessage$"),
                                                                        ])),

                                            TPPBPolicyKeyViewMapping(view: "CreditCards", matchingRule:
                                                                        TPDictionaryMatchingRule.orMatch([
                                                                            TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com\\.apple\\.safari\\.credit-cards$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^CreditCards$"),
                                                                        ])),

                                            TPPBPolicyKeyViewMapping(view: "Passwords", matchingRule:
                                                                        TPDictionaryMatchingRule.orMatch([
                                                                            TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com\\.apple\\.cfnetwork$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com\\.apple\\.cfnetwork-recently-deleted$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com\\.apple\\.password-manager$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com\\.apple\\.password-manager-recently-deleted$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com\\.apple\\.WebKit\\.WebAuthn$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com\\.apple\\.webkit\\.webauthn$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com\\.apple\\.webkit\\.webauthn-recently-deleted$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com\\.apple\\.password-manager\\.personal$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com\\.apple\\.password-manager\\.personal-recently-deleted$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com\\.apple\\.password-manager\\.generated-passwords$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com\\.apple\\.password-manager\\.generated-passwords-recently-deleted$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^Passwords$"),
                                                                        ])),

                                            TPPBPolicyKeyViewMapping(view: "DevicePairing", matchingRule:
                                                                        TPDictionaryMatchingRule.orMatch([
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^AccessoryPairing$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^NanoRegistry$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^WatchMigration$"),
                                                                        ])),

                                            TPPBPolicyKeyViewMapping(view: "Backstop", matchingRule:
                                                                        TPDictionaryMatchingRule.trueMatch()),
                                          ],
                                          userControllableViewList: [
                                            "Applications",
                                            "Backstop",
                                            "CreditCards",
                                            "Passwords",
                                            "WiFi",
                                          ],
                                          piggybackViews: [
                                            "Passwords",
                                          ],
                                          priorityViews: [
                                            "ProtectedCloudStorage",
                                            "SecureObjectSync",
                                          ],
                                          inheritedExcludedViews: [
                                            "Passwords",
                                          ],
                                          hashAlgo: .SHA256)}),

    RawPolicy(
        version: TPPolicyVersion(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XNzd29yZHNKFVByb3RlY3RlZENsb3VkU3RvcmFnZUoQU2VjdXJlT2JqZWN0U3luY1IJUGFzc3dvcmRz" },
        plaintextPolicy: {TPPolicyDocument(version: 19,
                                          modelToCategory: [
                                            TPPBPolicyModelToCategory(prefix: "AppleTV", category: "tv"),
                                            TPPBPolicyModelToCategory(prefix: "AudioAccessory", category: "audio"),
                                            TPPBPolicyModelToCategory(prefix: "Mac", category: "full"),
                                            TPPBPolicyModelToCategory(prefix: "Watch", category: "watch"),
                                            TPPBPolicyModelToCategory(prefix: "WinPC", category: "windows"),
                                            TPPBPolicyModelToCategory(prefix: "iMac", category: "full"),
                                            TPPBPolicyModelToCategory(prefix: "iPad", category: "full"),
                                            TPPBPolicyModelToCategory(prefix: "iPhone", category: "full"),
                                            TPPBPolicyModelToCategory(prefix: "iPod", category: "full"),
                                            TPPBPolicyModelToCategory(prefix: "RealityDevice", category: "full"),
                                          ],
                                          categoriesByView: [
                                            TPPBPolicyCategoriesByView(view: "ApplePay", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "Applications", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "AutoUnlock", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "Backstop", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "CreditCards", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "Contacts", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "DevicePairing", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "Engram", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "Groups", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "Health", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "Home", categories: ["full", "watch", "tv", "audio"]),
                                            TPPBPolicyCategoriesByView(view: "LimitedPeersAllowed", categories: ["windows", "full", "watch", "tv", "audio"]),
                                            TPPBPolicyCategoriesByView(view: "Mail", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "MFi", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "Manatee", categories: ["full", "watch", "windows"]),
                                            TPPBPolicyCategoriesByView(view: "Passwords", categories: ["full", "watch", "windows"]),
                                            TPPBPolicyCategoriesByView(view: "Photos", categories: ["full", "watch", "windows"]),
                                            TPPBPolicyCategoriesByView(view: "ProtectedCloudStorage", categories: [ "windows", "full", "watch", "tv", "audio"]),
                                            TPPBPolicyCategoriesByView(view: "SecureObjectSync", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "WiFi", categories: ["full", "watch", "tv", "audio"]),
                                          ],
                                          introducersByCategory: [
                                            TPPBPolicyIntroducersByCategory(category: "audio", introducers: ["full", "watch", "audio"]),
                                            TPPBPolicyIntroducersByCategory(category: "full", introducers: ["full", "watch"]),
                                            TPPBPolicyIntroducersByCategory(category: "tv", introducers: ["full", "watch", "tv"]),
                                            TPPBPolicyIntroducersByCategory(category: "watch", introducers: ["full", "watch"]),
                                            TPPBPolicyIntroducersByCategory(category: "windows", introducers: ["full", "watch"]),
                                          ],
                                          redactions: [],
                                          keyViewMapping: [
                                            TPPBPolicyKeyViewMapping(view: "ApplePay", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^ApplePay$")),
                                            TPPBPolicyKeyViewMapping(view: "AutoUnlock", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^AutoUnlock$")),
                                            TPPBPolicyKeyViewMapping(view: "Engram", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^Engram$")),
                                            TPPBPolicyKeyViewMapping(view: "Health", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^Health$")),
                                            TPPBPolicyKeyViewMapping(view: "Home", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^Home$")),
                                            TPPBPolicyKeyViewMapping(view: "Manatee", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^Manatee$")),
                                            TPPBPolicyKeyViewMapping(view: "LimitedPeersAllowed", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^LimitedPeersAllowed$")),

                                            // These items will not be synced by Octagon
                                            TPPBPolicyKeyViewMapping(view: "NotSynced", matchingRule:
                                                                        TPDictionaryMatchingRule.orMatch([
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^ContinuityUnlock$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^HomeKit$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^AppleTV$"),
                                                                        ])),

                                            TPPBPolicyKeyViewMapping(view: "MFi", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^MFi$")),
                                            TPPBPolicyKeyViewMapping(view: "Mail", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^Mail$")),
                                            TPPBPolicyKeyViewMapping(view: "Contacts", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^Contacts$")),
                                            TPPBPolicyKeyViewMapping(view: "Photos", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^Photos$")),
                                            TPPBPolicyKeyViewMapping(view: "Groups", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^Groups$")),

                                            TPPBPolicyKeyViewMapping(view: "Applications", matchingRule:
                                                                        TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^[0-9A-Z]{10}\\.")),

                                            TPPBPolicyKeyViewMapping(view: "SecureObjectSync", matchingRule:
                                                                        TPDictionaryMatchingRule.orMatch([
                                                                            TPDictionaryMatchingRule.andMatch([
                                                                                TPDictionaryMatchingRule.fieldMatch("class", fieldRegex: "^genp$"),
                                                                                TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com\\.apple\\.sbd$"),
                                                                            ]),
                                                                            TPDictionaryMatchingRule.andMatch([
                                                                                TPDictionaryMatchingRule.fieldMatch("class", fieldRegex: "^keys$"),
                                                                                TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com\\.apple\\.security\\.sos$"),
                                                                            ]),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^BackupBagV0$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^iCloudIdentity$"),
                                                                        ])),

                                            TPPBPolicyKeyViewMapping(view: "WiFi", matchingRule:
                                                                        TPDictionaryMatchingRule.orMatch([
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^WiFi$"),
                                                                            TPDictionaryMatchingRule.andMatch([
                                                                                TPDictionaryMatchingRule.fieldMatch("class", fieldRegex: "^genp$"),
                                                                                TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^apple$"),
                                                                                TPDictionaryMatchingRule.fieldMatch("svce", fieldRegex: "^AirPort$"),
                                                                            ]),
                                                                        ])),

                                            TPPBPolicyKeyViewMapping(view: "ProtectedCloudStorage", matchingRule:
                                                                        TPDictionaryMatchingRule.orMatch([
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-Backup$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-CloudKit$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-Escrow$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-FDE$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-Feldspar$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-MailDrop$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-Maildrop$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-MasterKey$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-Notes$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-Photos$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-Sharing$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-iCloudBackup$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-iCloudDrive$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-iMessage$"),
                                                                        ])),

                                            TPPBPolicyKeyViewMapping(view: "CreditCards", matchingRule:
                                                                        TPDictionaryMatchingRule.orMatch([
                                                                            TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com\\.apple\\.safari\\.credit-cards$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^CreditCards$"),
                                                                        ])),

                                            TPPBPolicyKeyViewMapping(view: "Passwords", matchingRule:
                                                                        TPDictionaryMatchingRule.orMatch([
                                                                            TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com\\.apple\\.cfnetwork$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com\\.apple\\.cfnetwork-recently-deleted$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com\\.apple\\.password-manager$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com\\.apple\\.password-manager-recently-deleted$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com\\.apple\\.WebKit\\.WebAuthn$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com\\.apple\\.webkit\\.webauthn$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com\\.apple\\.webkit\\.webauthn-recently-deleted$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com\\.apple\\.password-manager\\.personal$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com\\.apple\\.password-manager\\.personal-recently-deleted$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com\\.apple\\.password-manager\\.generated-passwords$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com\\.apple\\.password-manager\\.generated-passwords-recently-deleted$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^Passwords$"),
                                                                        ])),

                                            TPPBPolicyKeyViewMapping(view: "DevicePairing", matchingRule:
                                                                        TPDictionaryMatchingRule.orMatch([
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^AccessoryPairing$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^NanoRegistry$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^WatchMigration$"),
                                                                        ])),

                                            TPPBPolicyKeyViewMapping(view: "Backstop", matchingRule:
                                                                        TPDictionaryMatchingRule.trueMatch()),
                                          ],
                                          userControllableViewList: [
                                            "Applications",
                                            "Backstop",
                                            "CreditCards",
                                            "Passwords",
                                            "WiFi",
                                          ],
                                          piggybackViews: [
                                            "Passwords",
                                          ],
                                          priorityViews: [
                                            "ProtectedCloudStorage",
                                            "SecureObjectSync",
                                          ],
                                          inheritedExcludedViews: [
                                            "Passwords",
                                          ],
                                          hashAlgo: .SHA256)}),
    RawPolicy(
        version: TPPolicyVersion(version: 20, hash: "SHA256:OIzjC3WyLGrM8GAd/EyIfVzTJdYmcGoKPFdQeWeRZTY="),
        policyData: { "CBQSDQoHQXBwbGVUVhICdHYSFwoOQXVkaW9BY2Nlc3NvcnkSBWF1ZGlvEgsKA01hYxIEZnVsbBIOCgVXYXRjaBIFd2F0Y2gSEAoFV2luUEMSB3dpbmRvd3MSDAoEaU1hYxIEZnVsbBIMCgRpUGFkEgRmdWxsEg4KBml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KHl5jb21cLmFwcGxlXC5XZWJLaXRcLldlYkF1dGhuJBIqAAQiJgIEYWdycAoeXmNvbVwuYXBwbGVcLndlYmtpdFwud2ViYXV0aG4kEjsABCI3AgRhZ3JwCi9eY29tXC5hcHBsZVwud2Via2l0XC53ZWJhdXRobi1yZWNlbnRseS1kZWxldGVkJBI0AAQiMAIEYWdycAooXmNvbVwuYXBwbGVcLnBhc3N3b3JkLW1hbmFnZXJcLnBlcnNvbmFsJBJFAAQiQQIEYWdycAo5XmNvbVwuYXBwbGVcLnBhc3N3b3JkLW1hbmFnZXJcLnBlcnNvbmFsLXJlY2VudGx5LWRlbGV0ZWQkEj8ABCI7AgRhZ3JwCjNeY29tXC5hcHBsZVwucGFzc3dvcmQtbWFuYWdlclwuZ2VuZXJhdGVkLXBhc3N3b3JkcyQSUAAEIkwCBGFncnAKRF5jb21cLmFwcGxlXC5wYXNzd29yZC1tYW5hZ2VyXC5nZW5lcmF0ZWQtcGFzc3dvcmRzLXJlY2VudGx5LWRlbGV0ZWQkEhcABCITAgR2d2h0CgteUGFzc3dvcmRzJBIJUGFzc3dvcmRzMm0KXAACEh4ABCIaAgR2d2h0ChJeQWNjZXNzb3J5UGFpcmluZyQSGgAEIhYCBHZ3aHQKDl5OYW5vUmVnaXN0cnkkEhwABCIYAgR2d2h0ChBeV2F0Y2hNaWdyYXRpb24kEg1EZXZpY2VQYWlyaW5nMg4KAgAGEghCYWNrc3RvcDoMQXBwbGljYXRpb25zOghCYWNrc3RvcDoLQ3JlZGl0Q2FyZHM6CVBhc3N3b3JkczoEV2lGaUIJUGFzc3dvcmRzShVQcm90ZWN0ZWRDbG91ZFN0b3JhZ2VKEFNlY3VyZU9iamVjdFN5bmNSCVBhc3N3b3Jkcw==" },
        plaintextPolicy: {TPPolicyDocument(version: 20,
                                          modelToCategory: [
                                            TPPBPolicyModelToCategory(prefix: "AppleTV", category: "tv"),
                                            TPPBPolicyModelToCategory(prefix: "AudioAccessory", category: "audio"),
                                            TPPBPolicyModelToCategory(prefix: "Mac", category: "full"),
                                            TPPBPolicyModelToCategory(prefix: "Watch", category: "watch"),
                                            TPPBPolicyModelToCategory(prefix: "WinPC", category: "windows"),
                                            TPPBPolicyModelToCategory(prefix: "iMac", category: "full"),
                                            TPPBPolicyModelToCategory(prefix: "iPad", category: "full"),
                                            TPPBPolicyModelToCategory(prefix: "iPhone", category: "full"),
                                            TPPBPolicyModelToCategory(prefix: "iPod", category: "full"),
                                            TPPBPolicyModelToCategory(prefix: "RealityDevice", category: "full"),
                                          ],
                                          categoriesByView: [
                                            TPPBPolicyCategoriesByView(view: "ApplePay", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "Applications", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "AutoUnlock", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "Backstop", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "CreditCards", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "Contacts", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "DevicePairing", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "Engram", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "Groups", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "Health", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "Home", categories: ["full", "watch", "tv", "audio"]),
                                            TPPBPolicyCategoriesByView(view: "LimitedPeersAllowed", categories: ["windows", "full", "watch", "tv", "audio"]),
                                            TPPBPolicyCategoriesByView(view: "Mail", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "MFi", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "Manatee", categories: ["full", "watch", "windows"]),
                                            TPPBPolicyCategoriesByView(view: "Passwords", categories: ["full", "watch", "windows"]),
                                            TPPBPolicyCategoriesByView(view: "Photos", categories: ["full", "watch", "tv", "windows"]),
                                            TPPBPolicyCategoriesByView(view: "ProtectedCloudStorage", categories: [ "windows", "full", "watch", "tv", "audio"]),
                                            TPPBPolicyCategoriesByView(view: "SecureObjectSync", categories: ["full", "watch"]),
                                            TPPBPolicyCategoriesByView(view: "WiFi", categories: ["full", "watch", "tv", "audio"]),
                                          ],
                                          introducersByCategory: [
                                            TPPBPolicyIntroducersByCategory(category: "audio", introducers: ["full", "watch", "audio"]),
                                            TPPBPolicyIntroducersByCategory(category: "full", introducers: ["full", "watch"]),
                                            TPPBPolicyIntroducersByCategory(category: "tv", introducers: ["full", "watch", "tv"]),
                                            TPPBPolicyIntroducersByCategory(category: "watch", introducers: ["full", "watch"]),
                                            TPPBPolicyIntroducersByCategory(category: "windows", introducers: ["full", "watch"]),
                                          ],
                                          redactions: [],
                                          keyViewMapping: [
                                            TPPBPolicyKeyViewMapping(view: "ApplePay", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^ApplePay$")),
                                            TPPBPolicyKeyViewMapping(view: "AutoUnlock", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^AutoUnlock$")),
                                            TPPBPolicyKeyViewMapping(view: "Engram", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^Engram$")),
                                            TPPBPolicyKeyViewMapping(view: "Health", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^Health$")),
                                            TPPBPolicyKeyViewMapping(view: "Home", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^Home$")),
                                            TPPBPolicyKeyViewMapping(view: "Manatee", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^Manatee$")),
                                            TPPBPolicyKeyViewMapping(view: "LimitedPeersAllowed", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^LimitedPeersAllowed$")),

                                            // These items will not be synced by Octagon
                                            TPPBPolicyKeyViewMapping(view: "NotSynced", matchingRule:
                                                                        TPDictionaryMatchingRule.orMatch([
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^ContinuityUnlock$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^HomeKit$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^AppleTV$"),
                                                                        ])),

                                            TPPBPolicyKeyViewMapping(view: "MFi", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^MFi$")),
                                            TPPBPolicyKeyViewMapping(view: "Mail", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^Mail$")),
                                            TPPBPolicyKeyViewMapping(view: "Contacts", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^Contacts$")),
                                            TPPBPolicyKeyViewMapping(view: "Photos", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^Photos$")),
                                            TPPBPolicyKeyViewMapping(view: "Groups", matchingRule: TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^Groups$")),

                                            TPPBPolicyKeyViewMapping(view: "Applications", matchingRule:
                                                                        TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^[0-9A-Z]{10}\\.")),

                                            TPPBPolicyKeyViewMapping(view: "SecureObjectSync", matchingRule:
                                                                        TPDictionaryMatchingRule.orMatch([
                                                                            TPDictionaryMatchingRule.andMatch([
                                                                                TPDictionaryMatchingRule.fieldMatch("class", fieldRegex: "^genp$"),
                                                                                TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com\\.apple\\.sbd$"),
                                                                            ]),
                                                                            TPDictionaryMatchingRule.andMatch([
                                                                                TPDictionaryMatchingRule.fieldMatch("class", fieldRegex: "^keys$"),
                                                                                TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com\\.apple\\.security\\.sos$"),
                                                                            ]),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^BackupBagV0$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^iCloudIdentity$"),
                                                                        ])),

                                            TPPBPolicyKeyViewMapping(view: "WiFi", matchingRule:
                                                                        TPDictionaryMatchingRule.orMatch([
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^WiFi$"),
                                                                            TPDictionaryMatchingRule.andMatch([
                                                                                TPDictionaryMatchingRule.fieldMatch("class", fieldRegex: "^genp$"),
                                                                                TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^apple$"),
                                                                                TPDictionaryMatchingRule.fieldMatch("svce", fieldRegex: "^AirPort$"),
                                                                            ]),
                                                                        ])),

                                            TPPBPolicyKeyViewMapping(view: "ProtectedCloudStorage", matchingRule:
                                                                        TPDictionaryMatchingRule.orMatch([
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-Backup$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-CloudKit$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-Escrow$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-FDE$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-Feldspar$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-MailDrop$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-Maildrop$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-MasterKey$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-Notes$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-Photos$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-Sharing$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-iCloudBackup$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-iCloudDrive$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^PCS-iMessage$"),
                                                                        ])),

                                            TPPBPolicyKeyViewMapping(view: "CreditCards", matchingRule:
                                                                        TPDictionaryMatchingRule.orMatch([
                                                                            TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com\\.apple\\.safari\\.credit-cards$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^CreditCards$"),
                                                                        ])),

                                            TPPBPolicyKeyViewMapping(view: "Passwords", matchingRule:
                                                                        TPDictionaryMatchingRule.orMatch([
                                                                            TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com\\.apple\\.cfnetwork$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com\\.apple\\.cfnetwork-recently-deleted$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com\\.apple\\.password-manager$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com\\.apple\\.password-manager-recently-deleted$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com\\.apple\\.WebKit\\.WebAuthn$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com\\.apple\\.webkit\\.webauthn$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com\\.apple\\.webkit\\.webauthn-recently-deleted$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com\\.apple\\.password-manager\\.personal$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com\\.apple\\.password-manager\\.personal-recently-deleted$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com\\.apple\\.password-manager\\.generated-passwords$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("agrp", fieldRegex: "^com\\.apple\\.password-manager\\.generated-passwords-recently-deleted$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^Passwords$"),
                                                                        ])),

                                            TPPBPolicyKeyViewMapping(view: "DevicePairing", matchingRule:
                                                                        TPDictionaryMatchingRule.orMatch([
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^AccessoryPairing$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^NanoRegistry$"),
                                                                            TPDictionaryMatchingRule.fieldMatch("vwht", fieldRegex: "^WatchMigration$"),
                                                                        ])),

                                            TPPBPolicyKeyViewMapping(view: "Backstop", matchingRule:
                                                                        TPDictionaryMatchingRule.trueMatch()),
                                          ],
                                          userControllableViewList: [
                                            "Applications",
                                            "Backstop",
                                            "CreditCards",
                                            "Passwords",
                                            "WiFi",
                                          ],
                                          piggybackViews: [
                                            "Passwords",
                                          ],
                                          priorityViews: [
                                            "ProtectedCloudStorage",
                                            "SecureObjectSync",
                                          ],
                                          inheritedExcludedViews: [
                                            "Passwords",
                                          ],
                                          hashAlgo: .SHA256)}),
]}

func validatePolicies() -> Bool {
    let prevailing: TPPolicyDocument? = rawPolicies().reduce(nil) { current, raw in
        let doc = raw.policyDoc()
        let plaintextPolicy = raw.plaintextPolicy()
        if !doc.isEqual(to: plaintextPolicy) {
            let version = plaintextPolicy.version.versionNumber
            let hash = plaintextPolicy.version.policyHash
            let bodyData = plaintextPolicy.protobuf
            let bodyBase64 = bodyData.base64EncodedString()
            logger.info("raw policy (plaintext version \(version, privacy: .public)) doesn't match encoding the plaintext bytes, new hash would be: \(hash, privacy: .public) new data: \(bodyBase64, privacy: .public)")
            assert(false)
        }

        assert(doc.version.versionNumber == raw.version.versionNumber)
        if raw.version.versionNumber == prevailingPolicyVersion.versionNumber {
            assert(!reservedVersions.contains(raw.version.versionNumber)) // prevailing can't also be reserved!
            assert(prevailingPolicyVersion.policyHash == raw.version.policyHash)
            assert(current == nil) // there can be only one prevailing policy
            return doc
        } else {
            return current
        }
    }
    assert(prevailing != nil) // the reduce must have returned a prevailing policy

    // double-check prevailingPolicyDoc below, albeit only used by unit tests
    assert(prevailingPolicyDoc != nil)

    return true
}

var prevailingPolicyDoc: TPPolicyDocument? = rawPolicies().first { $0.version.versionNumber == prevailingPolicyVersion.versionNumber }?.policyDoc()

func builtInPolicyDocumentsFilteredByVersion(_ block: (TPCounter) -> Bool) -> [() -> TPPolicyDocument] {
    return rawPolicies().filter { block($0.version.versionNumber) }.map { $0.policyDoc }
}
